Pandas query function not working with spaces in column names May 11, 2023 by Tarik From pandas 0.25 onward you will be able to escape column names with backticks so you can do a.query('`a b` == 5')