小编use*_*205的帖子

在pandas timeseries数据帧中查找条件以来的最大值

我试图找到最大值,因为在熊猫数据帧中条件是真的.我已经搜索了类似的问题并阅读了文档,但未能找到这个问题.为了说明,我想要一个将返回下面的maxsince列的函数.

In [84]: df
Out[84]: 
                     a      b  maxsince
2007-04-27 11:00:00  1   True         1
2007-04-27 11:30:00  5  False         5
2007-04-27 12:00:00  3  False         5
2007-04-27 12:30:00  2   True         2
2007-04-27 13:00:00  2  False         2
2007-04-27 13:30:00  7   True         7
2007-04-27 14:00:00  3  False         7
2007-04-27 14:30:00  4  False         7
Run Code Online (Sandbox Code Playgroud)

我无法通过循环计算这个问题.什么是最有效的方式?谢谢.

python numpy pandas

5
推荐指数
1
解决办法
982
查看次数

标签 统计

numpy ×1

pandas ×1

python ×1