You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While using a groupby, applying an expanding function duplicates the grouped dimensions. I would expect the result of this to work like groupby.cumsum where the expanding function is applied over the groups and then the result has the same index as the original data frame.
Code Sample, a copy-pastable example if possible
My Data Frame sample
>>> dataframe
one
cont cat1
0 a 0
b 1
1 a 2
b 3
2 a 4
b 5
3 a 6
b 7
4 a 8
b 9
5 a 10
b 11
6 a 12
b 13
7 a 14
b 15
Example of the function call and incorrect output.
>>> dataframe.groupby(level=1).expanding(min_periods=1).mean()
one
cat1 cont cat1
a 0 a 0.0
1 a 1.0
2 a 2.0
3 a 3.0
4 a 4.0
5 a 5.0
6 a 6.0
7 a 7.0
b 0 b 1.0
1 b 2.0
2 b 3.0
3 b 4.0
4 b 5.0
5 b 6.0
6 b 7.0
7 b 8.0
Expected Output
>>> dataframe.groupby(level=1).cumsum()
one
cont cat1
0 a 0.0
b 1.0
1 a 1.0
b 2.0
2 a 2.0
b 3.0
3 a 3.0
b 4.0
4 a 4.0
b 5.0
5 a 5.0
b 6.0
6 a 6.0
b 7.0
7 a 7.0
b 8.0
While using a
groupby
, applying anexpanding
function duplicates the grouped dimensions. I would expect the result of this to work likegroupby.cumsum
where theexpanding
function is applied over the groups and then the result has the same index as the original data frame.Code Sample, a copy-pastable example if possible
My Data Frame sample
Example of the function call and incorrect output.
Expected Output
output of
pd.show_versions()
The text was updated successfully, but these errors were encountered: