如何从Pandas Series对象中检索特定值的标签名称:
例如:
labels = ['a', 'b', 'c', 'd', 'e']
s = Series (arange(5) * 4 , labels)
生成该系列的方法为:
a 0
b 4
c 8
d 12
e 16
dtype: int64
如何获取值为'12'的标签?谢谢。
您可以通过以下方式获取子序列:
In [90]: s[s==12]
Out[90]:
d 12
dtype: int64
此外,您可以通过
In [91]: s[s==12].index
Out[91]: Index([d], dtype=object)