diff --git a/audformat/core/utils.py b/audformat/core/utils.py index b201808a..8945357d 100644 --- a/audformat/core/utils.py +++ b/audformat/core/utils.py @@ -672,6 +672,12 @@ def hash( independent of the ordering of the elements, and level or column names. + .. warning:: + + If ``obj`` is a dataframe or series + with data type ``"Int64"``, + the returned hash value changes with ``pandas>=2.2.0``. + Args: obj: object diff --git a/tests/test_utils.py b/tests/test_utils.py index d124e057..79cd6028 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -509,6 +509,50 @@ def test_expand_file_path(tmpdir, index, root, expected): pd.DataFrame([0, 1], columns=["name"]), "-7179254265801896228", ), + pytest.param( + pd.DataFrame( + [0, 1, 2], + pd.Index([0, 1, 2], dtype="Int64"), + ), + "5440931770055407318", + marks=pytest.mark.skipif( + pd.__version__ >= "2.2.0", + reason="Changed in pandas 2.2.0", + ), + ), + pytest.param( + pd.DataFrame( + [0, 1, 2], + pd.Index([0, 1, 2], dtype="Int64"), + ), + "-5491649331962632325", + marks=pytest.mark.skipif( + pd.__version__ < "2.2.0", + reason="Changed in pandas 2.2.0", + ), + ), + pytest.param( + pd.Series( + [0, 1, 2], + pd.Index([0, 1, 2], dtype="Int64"), + ), + "5440931770055407318", + marks=pytest.mark.skipif( + pd.__version__ >= "2.2.0", + reason="Changed in pandas 2.2.0", + ), + ), + pytest.param( + pd.Series( + [0, 1, 2], + pd.Index([0, 1, 2], dtype="Int64"), + ), + "-5491649331962632325", + marks=pytest.mark.skipif( + pd.__version__ < "2.2.0", + reason="Changed in pandas 2.2.0", + ), + ), ], ) def test_hash(obj, expected):