Which month of the year has the highest number of accidents?
There are a couple of ways to do this. Here is a very clean and self-explanatory version. First, we'll calculate the monthly sum of accidents:
monthly_accidents = accidents['crash_count'].resample('M').sum()
Then we'll reformat the index so that it contains only the number of the month:
monthly_accidents.index = monthly_accidents.index.month
Then we can ask for the row which contains the maximum value of the series:
monthly_accidents[monthly_accidents == monthly_accidents.max()]
If we want just the month number, we can do:
maxmonth = monthly_accidents[monthly_accidents == monthly_accidents.max()].index[0]
maxmonth
And if we want to get really fancy, we can use the calendar module to get the month name instead of just the number:
import calendar
calendar.month_name[maxmonth]
¯\_(ツ)_/¯