Why is it normal for an index with lists to be like values, but not approved for columns?

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?

+6
source share
1 answer

"unhashable type" , , , . Mutable , , -. , , , , .

-1

All Articles