There is a Pandas function: df[['performer', 'time_on_chart']].groupby('performer').agg({'min', 'max'}) Sort it by 'max' column
df = pd.DataFrame([['a', 1, 2], ['a', 2, 3], ['b', 2, 3]], columns = ['performer', 'min', 'max']) def sort_by_max(df, groupby_column, column_to_sort): return df[[groupby_column, column_to_sort]].groupby(groupby_column).agg({'min', 'max'}).sort_values(by=column_to_sort) sort_by_max(df, 'performer', 'max')