From e33b1e51a6e858d8143c4a95da16efa118fd4b47 Mon Sep 17 00:00:00 2001 From: Brian Hulette Date: Mon, 14 Jun 2021 13:20:45 -0700 Subject: [PATCH] CLN: Verify non-ndarray is an ExtensionArray in hash_array GH42003 --- pandas/core/util/hashing.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pandas/core/util/hashing.py b/pandas/core/util/hashing.py index fb5002648b6a5..16aca46333052 100644 --- a/pandas/core/util/hashing.py +++ b/pandas/core/util/hashing.py @@ -286,6 +286,8 @@ def hash_array( return _hash_categorical(vals, encoding, hash_key) elif not isinstance(vals, np.ndarray): # i.e. ExtensionArray + if not hasattr(vals, '_values_for_factorize'): + raise TypeError("must pass ndarray or ExtensionArray") vals, _ = vals._values_for_factorize() return _hash_ndarray(vals, encoding, hash_key, categorize)