Dec-09-2017, 08:05 PM
import pandas as pd data = [1.0, 2.0, 3.0, 4.0] s1 = pd.Series(data) rollmean = pd.rolling_mean(s1, 2) print(rollmean)Hello, I changed my code according to your advice, but I got some warning:
Warning: pd.rolling_mean is deprecated for Series and will be removed in a future version, replace with
Series.rolling(window=2, center=False).mean()
However, I did see the result:
0 NaN
1 1.5
2 2.5
3 3.5
dtype: float64
I want to know how to use the new version or the version in future to do the same job.
Another issue is: the first value is: NaN
How I can either delete the first value or replace the value NaN by another value, i.e. 0.0
Thanks,