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 \
query
I am afraid that the query method does not accept column name with empty space. In any case you can query the dataframe in this way:
import pandas as pd a = pd.DataFrame({'a b':[1,2,3,4], 'c':[5,6,7,8]}) a[a['a b']==1]