I want to get all the top (max) months base on the count of each month in one column:
month
Oct
Oct
Oct
Jan
Jan
Jan
Feb
Feb
Aug
in this case, Oct and Jan are both top months with 3 counts.
With below code, I can only get one of the top months. How can I get the output for all the top months (Oct and Jan) instead of only Oct or Jan? The problem is I am not sure how to detect how many months with same max count.
top_month = df.groupby('month')['month'].count().sort_values().tail(1).index.values[0]
This output I want is:
Top month: Oct, Jan