necomancer
2021-11-11 00:38:01 +08:00
In [2]: ret = []
In [2]: for i in range(7, a.shape[0]+1):
...: m = np.argmin(a[i-7:i]) +i -7
...: ret.append((m, a[m], m==i-1))
...:
In [3]: ret
Out[3]:
[(4, 0.1070058697941636, False), # (绝对索引,值,当日是否为当周(前 7 日)最低)
(4, 0.1070058697941636, False),
(4, 0.1070058697941636, False),
(4, 0.1070058697941636, False),
(4, 0.1070058697941636, False),
(7, 0.38082268305528855, False),
(7, 0.38082268305528855, False),
(13, 0.3198102115371413, True),
(13, 0.3198102115371413, False),
(15, 0.26007158139013975, True),
(15, 0.26007158139013975, False),
(15, 0.26007158139013975, False),
(18, 0.1774755070886418, True),
(18, 0.1774755070886418, False)]
In [4]: a
Out[4]:
array([0.59171944, 0.95287085, 0.56036765, 0.91771266, 0.10700587,
0.67920182, 0.40034268, 0.38082268, 0.81140219, 0.78271362,
0.43178875, 0.7328393 , 0.93324926, 0.31981021, 0.74938937,
0.26007158, 0.33768583, 0.78881252, 0.17747551, 0.27862649])