Closed
Description
For this SO question I isolated a regression in DataFrameGroupBy.head()
between 0.12.0 and 0.13.0.
In [1]: df = pd.DataFrame({'A': ['one', 'one', 'two', 'three', 'three', 'one'], 'B': range(6)})
In 0.12.0:
In [2]: df.groupby('A').head()
Out[2]:
A B
A
one 0 one 0
1 one 1
5 one 5
three 3 three 3
4 three 4
two 2 two 2
which effectively returns the rows of the underlying .obj
sorted by group. In 0.13.0:
In [2]: df.groupby('A').head()
Out[2]:
A B
A
one 0 one 0
1 one 1
two 2 two 2
three 3 three 3
4 three 4
one 5 one 5
[6 rows x 2 columns]
which returns the rows of the underlying .obj
in their original order. The former is more intuitive.