python pandas display the highest number of rows in a column for each distinct value in another column

You want to groupby over vehicle type and then aggregate the mode for each group:

data.groupby('Vehicle_type')['Color'].agg(pd.Series.mode)

Vehicle_type
1    12
2    10
3    13
4    14
5    11
Name: Color, dtype: int64

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top