I have a time series object grouped
of the type <pandas.core.groupby.SeriesGroupBy object at 0x03F1A9F0>
. grouped.sum()
gives the desired result but I cannot get rolling_sum to work with the groupby
object. Is there any way to apply rolling functions to groupby
objects? For example:
x = range(0, 6)
id = ['a', 'a', 'a', 'b', 'b', 'b']
df = DataFrame(zip(id, x), columns = ['id', 'x'])
df.groupby('id').sum()
id x
a 3
b 12
However, I would like to have something like:
id x
0 a 0
1 a 1
2 a 3
3 b 3
4 b 7
5 b 12
Question&Answers:os