1/19/2022

pandas moving average

 

Average by 2 steps moving window

.

import pandas as pd
data=[100, 200, 100, 100, 200, 100]
df = pd.DataFrame(data)
df.rolling(2).mean()

.

    0
0 NaN
1 150.0
2 150.0
3 100.0
4 150.0
5 150.0


www.marearts.com
๐Ÿ™‡๐Ÿป‍♂️

No comments:

Post a Comment