I am looking to use pd.rolling_mean
in a groupby
operation. I want to have in each group a rolling mean of the previous elemnets within the same group. Here is an example:
id val
0 1
0 2
0 3
1 4
1 5
2 6
Grouping by id
, this should be transformed into:
id val
0 nan
0 1
0 1.5
1 nan
1 4
2 nan