在Pandas系列中,它指出索引值必须是唯一的和可理解的。但是,当提供重复索引时,它仍然存储两个值,并且不删除以前与相同索引对应的值,这与Python中的Dictionary中的情况不同。为什么会这样呢?它是否避免冲突并存储与同一索引对应的两个值?准确地说,这是我的密码-
d=pd.Series(['Saurabh','Singh','Bazzad'],[1,2,1])
我打印d时得到的输出是-
1 Saurabh
2 Singh
1 Bazzad
发布于 2018-09-15 17:06:52
来自index
pandas.Series
的docstring
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.
如前所述,非唯一值是允许的.
https://stackoverflow.com/questions/52346654
复制相似问题