Python Pandas Cumsum With Shift Of N
I would like to know if there is an efficient way (avoiding for loops) of doing a serie.cumsum() but with a shift of n. The same way you can see serie.cumsum() like the inverse of
Solution 1:
You can use the pandas method rolling.sum() among with sum:
s.rolling(shift).sum()
However you may want to fill the NaN values until the shift with the original df.
Post a Comment for "Python Pandas Cumsum With Shift Of N"