熊猫系列从位置获取索引

时间:2020-04-15 12:29:04

标签: python-3.x pandas

我有一个pandas.Series对象s

s.iloc[5:9]返回以下内容:

>>> s.iloc[5:9]
date
2019-01-09    49.6
2019-01-10    79.3
2019-01-11    89.4
2019-01-14    61.7
Name: price, dtype: float64

是否可以使用'2019-01-09'及其对应位置s获得索引5

我的意思是我想要一个这样的函数:

>>> get_index_by_position(s, 5)
'2019-01-09'
>>> get_index_by_position(s, 6)
'2019-01-10'
>>> get_index_by_position(s, 8)
'2019-01-14'

如何实现get_index_by_position()

0 个答案:

没有答案