hash()

audformat.utils.hash(obj, strict=False)[source]

Create hash from object.

If strict is False, objects with the same elements produce the same hash string independent of the ordering of the elements, and level or column names.

Warning

If obj is a dataframe or series with data type "Int64", and strict is False, the returned hash value changes with pandas>=2.2.0.

Parameters
  • obj (Union[Index, Series, DataFrame]) – object

  • strict (bool) – if True, the hash takes into account the order of rows and column/level names

Return type

str

Returns

hash string with 19 characters, or 32 characters if strict is True

Examples

>>> index = filewise_index(["f1", "f2"])
>>> hash(index)
'-4231615416436839963'
>>> hash(index[::-1])  # reversed index
'-4231615416436839963'
>>> y = pd.Series(0, index)
>>> hash(y)
'5251663970176285425'
>>> hash(index, strict=True)
'0741235e2250e0fcd9ab7b64972f5047'
>>> hash(index[::-1], strict=True)  # reversed index
'c6639d377897dd9353dc3e8b2968170d'