在Pandas系列中,它表示索引值必须是唯一的并且是可哈希的。但是当提供重复索引时,它仍然存储两个值,并且不会像以前在Python词典中那样删除先前与同一索引对应的值。为什么这样?是否避免冲突并存储与同一Index对应的两个值? 正是这是我的代码-
d=pd.Series(['Saurabh','Singh','Bazzad'],[1,2,1])
打印d时得到的输出是-
1 Saurabh
2 Singh
1 Bazzad
答案 0 :(得分:0)
index
的 pandas.Series
文档字符串
index : array-like or Index (1d)
Values must be hashable and have the same length as `data`.
Non-unique index values are allowed. Will default to
RangeIndex (0, 1, 2, ..., n) if not provided. If both a dict and index
sequence are used, the index will override the keys found in the
dict.
如此处所述,允许非唯一值。