I would like to insert the rolling mean value to the row below and not in the same row as a window. I could use the shift method to achieve that, however you experts could tip me with much more efficient methods. Thank you!
df_ts['mittel'] =df_ts['convertedAccx'].rolling(2,min_periods=2).mean()
It works fine !
df1:
a
0 0
1 0
2 1
3 2
data_dic = {
"a": [0,0,1,2]
}
df1 = pd.DataFrame(data_dic)
print(df1['a'].rolling(2,min_periods=2).mean())
>>>
0 NaN
1 0.0
2 0.5
3 1.5
Please add a sample of your dataframe if you are still facing the issue.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.