Skip to main content
`Ctrl`+`K`

# pandas.api.types.is_hashable

pandas.api.types.is_hashable(obj, allow_slice=True)

  Return True if hash(obj) will succeed, False otherwise.

  Some types will pass a test against collections.abc.Hashable but fail when they are actually hashed with hash().

  Distinguish between these and other types by trying the call to hash() and seeing if they raise TypeError.

  Parameters:
    obj object

      The object to check for hashability. Any Python object can be passed here.

    allow_slice bool

      If True, return True if the object is hashable (including slices). If False, return True if the object is hashable and not a slice.

  Returns:
    bool

      True if object can be hashed (i.e., does not raise TypeError when passed to hash()) and passes the slice check according to ‘allow_slice’. False otherwise (e.g., if object is mutable like a list or dictionary or if allow_slice is False and object is a slice or contains a slice).

  See also

  `api.types.is_float`

    Return True if given object is float.

  `api.types.is_iterator`

    Check if the object is an iterator.

  `api.types.is_list_like`

    Check if the object is list-like.

  `api.types.is_dict_like`

    Check if the object is dict-like.

  Examples

      >>> import collections
      >>> from pandas.api.types import is_hashable
      >>> a = ([],)
      >>> isinstance(a, collections.abc.Hashable)
      True
      >>> is_hashable(a)
      False