【发布时间】:2013-05-02 09:21:03
【问题描述】:
如何在 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'的标签?谢谢
【问题讨论】:
如何在 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)
【讨论】: