Skip to content

Automatic PR for 6454e6f2-648d-4429-a580-ff8c6d8c5227 #78

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: 6454e6f2-648d-4429-a580-ff8c6d8c5227-base
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions pandas/core/util/hashing.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def hash_array(
encoding=encoding, hash_key=hash_key, categorize=categorize
)

if not isinstance(vals, np.ndarray):
elif not isinstance(vals, np.ndarray):
# GH#42003
raise TypeError(
"hash_array requires np.ndarray or ExtensionArray, not "
Expand All @@ -275,15 +275,14 @@ def _hash_ndarray(
"""
dtype = vals.dtype

# _hash_ndarray only takes 64-bit values, so handle 128-bit by parts
# we'll be working with everything as 64-bit values, so handle this
# 128-bit value early
if np.issubdtype(dtype, np.complex128):
hash_real = _hash_ndarray(vals.real, encoding, hash_key, categorize)
hash_imag = _hash_ndarray(vals.imag, encoding, hash_key, categorize)
return hash_real + 23 * hash_imag
return hash_array(np.real(vals)) + 23 * hash_array(np.imag(vals))

# First, turn whatever array this is into unsigned 64-bit ints, if we can
# manage it.
if dtype == bool:
elif dtype == bool:
vals = vals.astype("u8")
elif issubclass(dtype.type, (np.datetime64, np.timedelta64)):
vals = vals.view("i8").astype("u8", copy=False)
Expand Down Expand Up @@ -321,4 +320,4 @@ def _hash_ndarray(
vals ^= vals >> 27
vals *= np.uint64(0x94D049BB133111EB)
vals ^= vals >> 31
return vals
return vals