Skip to content

BUG: hash_pandas_object(obj).sum() changed value with pandas 2.1.0 #55452

Closed
@hagenw

Description

@hagenw

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

import pandas as pd

index = pd.Index(['f1', 'f2'], dtype='string', name='file')
pd.util.hash_pandas_object(index).sum()

Issue Description

Since version 2.1.0 of pandas the summation of the hashes returns a different value even thought the single hashes are still the same:

With pandas >= 2.1.0

>>> pd.util.hash_pandas_object(index)
file
f1    18078623642821437999
f2    14583249088160825270
dtype: uint64

>>> pd.util.hash_pandas_object(index).sum()
14215128657272711653

With pandas <= 2.0.3

>>> pd.util.hash_pandas_object(index)
file
f1    18078623642821437999
f2    14583249088160825270
dtype: uint64

>>> pd.util.hash_pandas_object(index).sum()
-4231615416436839963

Expected Behavior

No related changes are mentioned in https://pandas.pydata.org/pandas-docs/version/2.1.0/whatsnew/v2.1.0.html, so I would not expect a different behavior between the pandas versions.

Installed Versions

INSTALLED VERSIONS

commit : e86ed37
python : 3.10.11.final.0
python-bits : 64
OS : Linux
OS-release : 5.4.0-150-generic
Version : #167~18.04.1-Ubuntu SMP Wed May 24 00:51:42 UTC 2023
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_GB.UTF-8
LOCALE : en_GB.UTF-8

pandas : 2.1.1
numpy : 1.26.0
pytz : 2023.3.post1
dateutil : 2.8.2
setuptools : 68.2.2
pip : 23.2.1
Cython : None
pytest : 7.4.2
hypothesis : None
sphinx : 5.3.0
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.1.2
IPython : 8.16.1
pandas_datareader : None
bs4 : 4.12.2
bottleneck : None
dataframe-api-compat: None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
zstandard : None
tzdata : 2023.3
qtpy : None
pyqt5 : None

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions