Case 1 : the groupby is adding 'missing' combinations of 'A' an 'B' ?
Case 2 : the result is the same lengh as the entry dataframe.
If 'A' and 'B' represent integers, I get the same result in both cases.
Case 1 : the groupby is adding 'missing' combinations of 'A' an 'B' ?
Case 2 : the result is the same lengh as the entry dataframe.
If 'A' and 'B' represent integers, I get the same result in both cases.
Copyright © 2021 Jogjafile Inc.



When your keys are
categorydtype, the output contains the product of all combinations even if groups are missing due toobserved=Falsedefault setting ofgroupbymethod.If you use
sample.groupby(['A', 'B'], observed=True)['C'].count().reset_index(), the output will be the same whenAandBare integers.