enter image description here In code I have already created a month column and groupby it according to month but the months names are not sorted. How can I do it
CodePudding user response:
convert into list and this may help,
from calendar import month_name
month_lookup = list(month_name)
months = ['August', 'September', 'October', 'November', 'December', 'January']
sorted(months, key=month_lookup.index)
['January', 'August', 'September', 'October', 'November', 'December']
CodePudding user response:
My suggestion would be to do like answer #1 in this thread sketches out. Add another column to your dataframe with the month number and sort the dataframe by that column.
On another note: please remember to post code as plain text an not as images.