Skip to content

BUG: unhashable type error produced by pandas query #43842

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

Closed
2 of 3 tasks
vttrifonov opened this issue Oct 1, 2021 · 3 comments
Closed
2 of 3 tasks

BUG: unhashable type error produced by pandas query #43842

vttrifonov opened this issue Oct 1, 2021 · 3 comments
Labels
Bug Closing Candidate May be closeable, needs more eyeballs expressions pd.eval, query

Comments

@vttrifonov
Copy link

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the master branch of pandas.

Reproducible Example

import pandas as pd
x = pd.DataFrame({'a': [1,2]})
x = x.query('a.isna()')

Issue Description

The code above produces the following error. This is in being run in a fresh (nothing else) conda environment with only python3.7 and pandas 1.3.3 installed.

Traceback (most recent call last):
File "", line 1, in
File "/project_folder/env/lib/python3.7/site-packages/pandas/core/frame.py", line 4060, in query
res = self.eval(expr, **kwargs)
File "/project_folder/env/lib/python3.7/site-packages/pandas/core/frame.py", line 4191, in eval
return _eval(expr, inplace=inplace, **kwargs)
File "/project_folder/env/lib/python3.7/site-packages/pandas/core/computation/eval.py", line 353, in eval
ret = eng_inst.evaluate()
File "/project_folder/env/lib/python3.7/site-packages/pandas/core/computation/engines.py", line 80, in evaluate
res = self._evaluate()
File "/project_folder/env/lib/python3.7/site-packages/pandas/core/computation/engines.py", line 120, in _evaluate
_check_ne_builtin_clash(self.expr)
File "/project_folder/env/lib/python3.7/site-packages/pandas/core/computation/engines.py", line 36, in _check_ne_builtin_clash
names = expr.names
File "/project_folder/env/lib/python3.7/site-packages/pandas/core/computation/expr.py", line 833, in names
return frozenset([self.terms.name])
TypeError: unhashable type: 'Series'

Expected Behavior

Did not expect an error. Pretty sure this used to work, but now it does not. Considering that this happening in a fresh conda environment, not sure what in my setup could be causing this.

Installed Versions

INSTALLED VERSIONS

commit : 73c6825
python : 3.7.0.final.0
python-bits : 64
OS : Darwin
OS-release : 19.6.0
Version : Darwin Kernel Version 19.6.0: Thu Sep 16 20:58:47 PDT 2021; root:xnu-6153.141.40.1~1/RELEASE_X86_64
machine : x86_64
processor : i386
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8

pandas : 1.3.3
numpy : 1.20.3
pytz : 2021.1
dateutil : 2.8.2
pip : 21.2.2
setuptools : 58.0.4
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : None
IPython : None
pandas_datareader: None
bs4 : None
bottleneck : 1.3.2
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : None
numexpr : 2.7.3
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
numba : None

@vttrifonov vttrifonov added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Oct 1, 2021
@mzeitlin11
Copy link
Member

Thanks for the report @vttrifonov! Hopefully fixed by #43301?

@phofl
Copy link
Member

phofl commented Oct 1, 2021

Yeah works on master

@phofl phofl added the Closing Candidate May be closeable, needs more eyeballs label Oct 1, 2021
@vttrifonov vttrifonov changed the title BUG: BUG: unhashable type error produced by pandas query Oct 1, 2021
@lithomas1 lithomas1 added expressions pd.eval, query and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Oct 2, 2021
@rhshadrach
Copy link
Member

I'm seeing it work on master as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Closing Candidate May be closeable, needs more eyeballs expressions pd.eval, query
Projects
None yet
Development

No branches or pull requests

5 participants