pandas.core.groupby.DataFrameGroupBy.head
- DataFrameGroupBy.head(n=5)
Return first n rows of each group.
Similar to
.apply(lambda x: x.head(n)), but it returns a subset of rows from the original DataFrame with original index and order preserved (as_indexflag is ignored).- Parameters:
- n : int