I have the following dataframe:
A B
2021-05-19 07:00:00 Nan Nan
2021-05-19 07:30:00 0.00 Nan
2021-05-19 08:00:00 0.00 Nan
2021-05-19 08:30:00 0.00 Nan
2021-05-19 09:00:00 19.91 Nan
2021-05-19 09:30:00 0.11 Nan
2021-05-19 10:00:00 0.00 Nan
2021-05-19 10:30:00 22.99 Nan
2021-05-19 11:00:00 0.00 Nan
需求:
A B
2021-05-19 07:00:00 Nan 0.00
2021-05-19 07:30:00 0.00 0.00
2021-05-19 08:00:00 0.00 0.00
2021-05-19 08:30:00 0.00 0.00
2021-05-19 09:00:00 19.91 3.32
2021-05-19 09:30:00 0.11 2.78
2021-05-19 10:00:00 0.00 2.32
2021-05-19 10:30:00 22.99 5.76
2021-05-19 11:00:00 0.00 4.80
计算 B 列:
B1 = A1
B2 = ((B1*5)+A2)/6
B3 = ((B2*5)+A3)/6
B4 = ((B3*5)+A4)/6
etc.
我已经尝试使用Python的shift函数进行计算,但这并不起作用,如果有人能帮助我找到正确的方向,那就太好了。
shift
,因为下一个值取决于先前值的计算,依此类推。 - Anurag Dhadse