根据给定的阈值找到趋势斜率的偏差

时间:2019-12-19 13:35:38

标签: python pandas time-series signal-processing data-analysis

我有这样的时间序列:

Date,val
02/06/1980,0.9866
03/06/1980,0.9859
04/06/1980,0.9657
05/06/1980,0.9859
06/06/1980,0.9864
09/06/1980,0.9871
10/06/1980,0.9877
11/06/1980,0.9885
12/06/1980,0.9895
13/06/1980,0.9905
16/06/1980,0.9921
17/06/1980,0.9933
18/06/1980,0.9945
19/06/1980,0.9958
20/06/1980,0.9971
23/06/1980,0.9989
24/06/1980,1.0244
25/06/1980,1.0029
26/06/1980,1.005
27/06/1980,1.0068
30/06/1980,1.0082
01/07/1980,1.0096
02/07/1980,1.011
03/07/1980,1.0127
07/07/1980,1.0149
08/07/1980,1.0168
09/07/1980,1.0185
10/07/1980,1.0198
11/07/1980,1.0213
14/07/1980,1.0232
15/07/1980,1.025
16/07/1980,1.027
17/07/1980,1.0292
18/07/1980,1.0316
21/07/1980,1.0341
22/07/1980,1.0361
23/07/1980,1.038
24/07/1980,1.0399
25/07/1980,1.0415
28/07/1980,1.0431
29/07/1980,1.0448
30/07/1980,1.0464
31/07/1980,1.0481
01/08/1980,1.0497
04/08/1980,1.0512
05/08/1980,1.0528
06/08/1980,1.0543
07/08/1980,1.0561
08/08/1980,1.0582
11/08/1980,1.0604
12/08/1980,1.0623
13/08/1980,1.0641
14/08/1980,1.0661
15/08/1980,1.0681
18/08/1980,1.0698
19/08/1980,1.0714
20/08/1980,1.0732
21/08/1980,1.0749
22/08/1980,1.0764
25/08/1980,1.0778
26/08/1980,1.079

值列是63天移动平均值除以252天移动平均值的乘积。我想确定斜率从最近的底部上升5%(或更多)的时间段,以及斜率从最近的顶部下降5%(或更多)的时间段。结果应大致如下所示:

enter image description here

除了遍历数据框和定位底部/顶部并进行逐一比较之外,还有其他方法吗?我觉得这很简单,很难想象。

0 个答案:

没有答案