You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks for the report! Confirmed on main. It indeed looks like this is due to categorical as working with just strings gives the correct result. Further investigations and PRs to fix are welcome!
…HDFStore.select() return unexpected results.
In function __init__() of class Selection (pandas/core/io/pytables.py), the method self.terms.evaluate() was not
returning the correct value for the where condition. The issue stemmed from the function convert_value()
of class BinOp (pandas/core/computation/pytables.py), where the function searchedsorted() did not return the
correct index when matching the where condition in the metadata (categories table).
Replacing searchsorted() with np.where() resolves this issue.
SofiaSM45
added a commit
to SofiaSM45/pandas
that referenced
this issue
Mar 31, 2025
HDFStore.select() return unexpected results.
In function __init__() of class Selection (pandas/core/io/pytables.py),
the method self.terms.evaluate() was not returning the correct value
for the where condition. The issue stemmed from the function
convert_value() of class BinOp (pandas/core/computation/pytables.py),
where the function searchedsorted() did not return the correct index
when matching the where condition in the metadata (categories table).
Replacing searchsorted() with np.where() resolves this issue.
Pandas version checks
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 main branch of pandas.
Reproducible Example
Issue Description
This seems to be the same or very similar to bug #39189 (regression?)
I encountered the same behavior under pandas 2.2.0 and 2.2.1
Expected Behavior
The DataFrame stored in the HDF store is:
The 3 print statements give:
Installed Versions
INSTALLED VERSIONS
commit : bdc79c1
python : 3.11.8.final.0
python-bits : 64
OS : Linux
OS-release : 6.1.69-gentoo-dist-hardened
Version : #1 SMP PREEMPT_DYNAMIC Thu Jan 18 22:03:57 CET 2024
machine : x86_64
processor : AMD Ryzen 5 3600X 6-Core Processor
byteorder : little
LC_ALL : en_US.UTF-8
LANG : en_BE.UTF-8
LOCALE : en_US.UTF-8
pandas : 2.2.1
numpy : 1.26.4
pytz : 2024.1
dateutil : 2.8.2
setuptools : 69.0.3
pip : None
Cython : 3.0.8
pytest : 7.4.4
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : 3.1.9
lxml.etree : 4.9.4
html5lib : 1.1
pymysql : None
psycopg2 : None
jinja2 : 3.1.3
IPython : 8.21.0
pandas_datareader : None
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : 4.12.3
bottleneck : 1.3.7
dataframe-api-compat : None
fastparquet : None
fsspec : 2024.2.0
gcsfs : None
matplotlib : 3.8.2
numba : 0.59.0
numexpr : 2.9.0
odfpy : None
openpyxl : 3.1.2
pandas_gbq : None
pyarrow : None
pyreadstat : None
python-calamine : None
pyxlsb : None
s3fs : None
scipy : 1.12.0
sqlalchemy : 2.0.25
tables : 3.9.2
tabulate : 0.9.0
xarray : 2024.1.1
xlrd : 2.0.1
zstandard : 0.22.0
tzdata : None
qtpy : 2.4.1
pyqt5 : None
The text was updated successfully, but these errors were encountered: