Using Pandas, I have pulled in a CSV file and then created a series of the data to find out which days of the week have the most crashes:
crashes_by_day = bc['DAY_OF_WEEK'].value_counts()
I have then plotted this out, but of course it plots them in the same ranked order as the series.
crashes_by_day.plot(kind='bar')
What is the most efficient way to re-rank these to Mon, Tue, Wed, Thur, Fri, Sat, Sun?
Do I have to break it out into a list? Thanks.
You can use
Ordered Categorical
and thensort_index
:Next possible solution without
Categorical
is set sorting by mapping: