What is hashability in Python?
The property of an object that allows the user to use any datatype as a key in a hash table is known as hashability. It is the mostly commonly used when handling dictionaries and sets in Python. The hashable objects are mutable, i.e., there value can be modified after creation, while the non-hashable objects are immutable, whose value cannot be modified after creation.
Examples of hashable objects:
Integers, double, string, tuple, etc. falls under the category of hashable objects.
Integers:
int_value=100
Double:
double_value=100.00
String:
string_text="Geeks For Geeks"
Tuple:
tuple_value = (100, 200, 300)
Examples of non-hashable objects:
List, dictionary, set, etc. falls under the category of non hashable objects.
List:
list_value=[100, 200, 300]
Set:
set_value={100, 200, 300}
Dictionary:
dictionary_value={'a': 100, 'b': 200}
Typeerror: Unhashable Type: ‘Numpy.Ndarray’ in Python
The Python library used for working with arrays is known as NumPy. Python provides various exceptions, including TypeError, which occurs when a specific operation is performed on an unsupported object type. One common TypeError encountered by users is ‘TypeError: Unhashable Type: ‘numpy.ndarray’.’ In this article, we will discuss how to resolve this error.