Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何在熊猫系列对象中检索特定值的标签:
例如:
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)