Skip to content

Commit 9770e4e

Browse files
committed
do not use hash-function because for python>=3.10 it no longer has the desired behavior for nans
1 parent 861c211 commit 9770e4e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

pandas/core/dtypes/base.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
import numpy as np
1414

15+
from pandas._libs.hashtable import object_hash
1516
from pandas._typing import (
1617
DtypeObj,
1718
type_t,
@@ -128,7 +129,9 @@ def __eq__(self, other: Any) -> bool:
128129
return False
129130

130131
def __hash__(self) -> int:
131-
return hash(tuple(getattr(self, attr) for attr in self._metadata))
132+
# for python>=3.10, different nan objects have different hashes
133+
# we need to avoid that und thus use hash function with old behavior
134+
return object_hash(tuple(getattr(self, attr) for attr in self._metadata))
132135

133136
def __ne__(self, other: Any) -> bool:
134137
return not self.__eq__(other)

0 commit comments

Comments
 (0)