Consider numpy.array i
i = np.empty((1,), dtype=object)
i[0] = [1, 2]
i
array([list([1, 2])], dtype=object)
Example 1
index
df = pd.DataFrame([1], index=i)
df
0
[1, 2] 1
Example 2
columns
But
df = pd.DataFrame([1], columns=i)
It leads to this when I show it
df
TypeError: unhashable type: 'list'
However, it df.Tworks !?
Question
Why is it necessary for index values ββto be hashed in the context of the column, but not in the context of the index? And why only when it is displayed?
source
share