BUG: inconsistent name for returned Series in groupby · Issue #12363 · pandas-dev/pandas (original) (raw)
I would think [7]
and [8]
would be identical. Note this is true for all ops I have looked at, so it is a general issue.
In [6]: df = DataFrame({'A': ['foo', 'bar', 'foo', 'bar',
'foo', 'bar', 'foo', 'foo'],
'B': ['one', 'one', 'two', 'two',
'two', 'two', 'one', 'two'],
'C': np.random.randn(8) + 1.0,
'D': np.arange(8)})
In [7]: df.groupby(['A']).B.count()
Out[7]:
A
bar 3
foo 5
Name: B, dtype: int64
In [8]: df.B.groupby(df.A).count()
Out[8]:
A
bar 3
foo 5
dtype: int64