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
In the code, if we use groupby() following ['C'], the group size is 8, equal to the correct group size * field number, that is 2 * 4; if we use groupby() following column [['C']] or ['C','D'], the group size is right. If setting as_index to True, I can get a Series with correct value. But I want the groupby field 'A' included also, so as_index is set to False,
Expected Output
My expected output is that I can still get a DataFrame which should include column 'A' and 'C', and value of column 'C' is the group size, should be 2 in this code example.
The text was updated successfully, but these errors were encountered:
You probably want a transform but should ask on StackOverflow as the Q&A format of that site is much better suited to usage questions like this. This board is reserved for bug reports and enhancement requests
Pandas version: 0.22
Problem
I try to use the numpy.size() to count the group size for the groups from pandas Dataframe groupby(), and I get strange result.
Can any guys explain how the aggregation of groupby works?
In the code, if we use groupby() following ['C'], the group size is 8, equal to the correct group size * field number, that is 2 * 4; if we use groupby() following column [['C']] or ['C','D'], the group size is right. If setting as_index to True, I can get a Series with correct value. But I want the groupby field 'A' included also, so as_index is set to False,
Expected Output
My expected output is that I can still get a DataFrame which should include column 'A' and 'C', and value of column 'C' is the group size, should be 2 in this code example.
The text was updated successfully, but these errors were encountered: