
A “groupby” call in Python Pandas is normally sorted by index.
But if you’re grouping by month name, April will come before January.
Pass “sort=False”, and the index will reflect the order of appearance:
df.groupby('passenger_count', sort=False)['trip_distance'].mean()
