Skip to content

BUG: unhashable type error produced by pandas query #43842

Closed
@vttrifonov

Description

@vttrifonov

  • 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions