Pandas query function not working with spaces in column names

前端 未结 5 947
-上瘾入骨i
-上瘾入骨i 2020-11-30 10:45

I have a dataframe with spaces in column names. I am trying to use query method to get the results. It is working fine with \'c\' column but getting error for \

5条回答
  •  庸人自扰
    2020-11-30 11:32

    From pandas 0.25 onward you will be able to escape column names with backticks so you can do

    a.query('`a b` == 5') 
    

提交回复
热议问题