From 1c9a763a0a6e7b6ba4dcfd364a3fcb506883ba16 Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Thu, 12 Dec 2024 10:00:11 -0800 Subject: [PATCH] Ignore possible RuntimeWarning in _hash_ndarray --- pandas/core/util/hashing.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/pandas/core/util/hashing.py b/pandas/core/util/hashing.py index e120e69dc27cf..059d67e6d266e 100644 --- a/pandas/core/util/hashing.py +++ b/pandas/core/util/hashing.py @@ -6,6 +6,7 @@ import itertools from typing import TYPE_CHECKING +import warnings import numpy as np @@ -334,9 +335,15 @@ def _hash_ndarray( vals = hash_object_array(vals, hash_key, encoding) except TypeError: # we have mixed types - vals = hash_object_array( - vals.astype(str).astype(object), hash_key, encoding - ) + with warnings.catch_warnings(): + warnings.filterwarnings( + "ignore", + "invalid value encountered in cast", + RuntimeWarning, + ) + vals = hash_object_array( + vals.astype(str).astype(object), hash_key, encoding + ) # Then, redistribute these 64-bit ints within the space of 64-bit ints vals ^= vals >> 30