-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
df.query() does not support column name 'class' #18221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
While the error message could be better, I'm not sure this is something we can support (easily) - pandas and numexpr use the python parser to evaluate these expressions, and |
Understood, though this paragraph from the docstring made me believe it should work:
If it's impossible to use any reserved keywords as column names for |
Yes agreed, we may also want to wrap the parsing in a try/catch to bubble up a more directed error. PR welcome! |
I could get it to work with backticks: |
Code Sample, a copy-pastable example if possible
Problem description
Above code results in this error traceback:
My column names are "occ_id, class, et, radius, lon, width, type" and if I execute this query on another column, it works fine:
Only the column named 'class' seems to fail.
Expected Output
Sub selection of the dataframe according to the query.
Output of
pd.show_versions()
pandas: 0.21.0
pytest: 3.2.3
pip: 9.0.1
setuptools: 36.6.0
Cython: 0.27.3
numpy: 1.13.3
scipy: 0.19.1
pyarrow: None
xarray: 0.9.6
IPython: 6.2.1
sphinx: 1.6.5
patsy: 0.4.1
dateutil: 2.6.1
pytz: 2017.3
blosc: None
bottleneck: 1.2.1
tables: 3.4.2
numexpr: 2.6.4
feather: None
matplotlib: 2.1.0
openpyxl: None
xlrd: 1.1.0
xlwt: 1.3.0
xlsxwriter: None
lxml: None
bs4: 4.6.0
html5lib: 0.999999999
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.9.6
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
The text was updated successfully, but these errors were encountered: