I would like to use the function pandas.rolling_sumfor DataFrameto summarize the window using any data available for each window (so do not return NaNwhen the window goes beyond the available data). Here are some sample data:
import pandas as pd
df = pd.DataFrame([1]*4+[2]*4,
index=pd.date_range('2014-1-1', periods=8, freq='D'),
columns=['num'])
df.head()
Here is the main, centered, moving amount ...
pd.rolling_sum(df, 7, center=True)
I want to exclude values NaNand use any data available in each window. My guess was that the option would min_periodstake care of that ...
pd.rolling_sum(df, 7, center=True, min_periods=0)
This works when the window is not centered with center=True, but I am confused why the last three values ββare missing. I expected the last three values ββto be ...
- , min_periods , center=True ? ?