pandas.util.hash_array

pandas.util.hash_array(vals, encoding='utf8', hash_key=None, categorize=True)[source]

Given a 1d array, return an array of deterministic integers.

New in version 0.19.2.

Parameters
valsndarray, Categorical
encodingstring, default ‘utf8’

encoding for data & key when strings

hash_keystring key to encode, default to _default_hash_key
categorizebool, default True

Whether to first categorize object arrays before hashing. This is more efficient when the array contains duplicate values.

New in version 0.20.0.

Returns
1d uint64 numpy array of hash values, same length as the vals
Scroll To Top