我有一个数据帧:
Date Price
2021-01-01 29344.67
2021-01-02 32072.08
2021-01-03 33048.03
2021-01-04 32084.61
2021-01-05 34105.46
2021-01-06 36910.18
2021-01-07 39505.51
2021-01-08 40809.93
2021-01-09 40397.52
2021-01-10 38505.49
Date object
Price float64
dtype: object
我的目标是找到最长的连续增长期。
它应返回:
Longest consecutive period was from 2021-01-04 to 2021-01-08 with increase of $8725.32
老实说,我不知道从哪里开始。这是我学习熊猫的第一步,我不知道应该使用哪些工具来获取这些信息
有人能帮我指出正确的方向吗
使用cumsum在递减上检测递增顺序:
你会得到:
现在,您可以使用
你会得到:
类似于Quang所做的拆分组,然后选择组数
相关问题 更多 >
编程相关推荐