Closed
Description
Take the following example:
>>> df = pd.DataFrame(list(range(5)))
>>> df
0
0 0
1 1
2 2
3 3
4 4
>>> df.rolling(3, min_periods=1).sum()
0
0 0.0
1 1.0
2 3.0
3 6.0
4 9.0
There is no need to cast the ints to floats in this case since no NaNs have to be substituted for missing values when min_periods=1
. I think it would make sense to treat the case min_periods<=1
separately to prevent unnecessary type conversions like this one.