return rows after groupby pandas code example Example: dataframe, groupby, select one df.sort_values('date').groupby(['id', 'period', 'type']).first()