df:
id1 id2 value1 value2
-----------------------------------
a b 10 5
c a 5 10
b c 0 0
c d 2 1
d a 10 20
a c 5 10
get sum of values associated with id 'a' from column ['id1','id2']:
id1 id2 a.rolling(2).sum()
-----------------------------------
a b NaN
c a 20
d a 30
a c 25
How would I get the rolling sum of values of id 'a' from two different column with a df.groupby function?
I tried this df.groupby(['id1','id2])['value1','value2'].transform(lambda x: x.rolling(2).sum())
, but that did't work.