Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/310.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 与阈值超出相关的索引值_Python_Pandas - Fatal编程技术网

Python 与阈值超出相关的索引值

Python 与阈值超出相关的索引值,python,pandas,Python,Pandas,我对报告多个时间序列列中超过阈值的日期感兴趣。索引是与时间序列数据相关的站点位置相关的日期时间值和列名。我需要一个类似于“idxmax”的函数,但要返回时间序列中首次超过阈值的索引。这似乎是一项简单的任务,但我是Python的新用户,需要一些指导。谢谢 似乎idxmax可以满足以下要求: In [44]: x = pd.Series([1,2,3,4,5], index=pd.date_range('2000-1-1', periods=5, freq='M')) In [45]: x Out

我对报告多个时间序列列中超过阈值的日期感兴趣。索引是与时间序列数据相关的站点位置相关的日期时间值和列名。我需要一个类似于“idxmax”的函数,但要返回时间序列中首次超过阈值的索引。这似乎是一项简单的任务,但我是Python的新用户,需要一些指导。谢谢

似乎
idxmax
可以满足以下要求:

In [44]: x = pd.Series([1,2,3,4,5], index=pd.date_range('2000-1-1', periods=5, freq='M'))

In [45]: x
Out[45]: 
2000-01-31    1
2000-02-29    2
2000-03-31    3
2000-04-30    4
2000-05-31    5
Freq: M, dtype: int64

In [46]: x >= 3
Out[46]: 
2000-01-31    False
2000-02-29    False
2000-03-31     True
2000-04-30     True
2000-05-31     True
Freq: M, dtype: bool

In [47]: (x >= 3).idxmax()
Out[47]: Timestamp('2000-03-31 00:00:00', tz=None)

@用户2989613如果您认为此答案解决了您的问题,单击左侧的箭头可以接受此答案