Sort dataframe by date column stored as string I have dataframe named df1.

I want to sort data frame month column according to month (Jan, Feb, March..). 

For that I used code:

sorted_df = df1.sort_values(by='month')
print(sorted_df)


but the output is sorted by alphabetic order of month column.

I think the reason for that in this month column data type is object so month column is sorted by alphabetic order. 

The question is: how sort values in column month in correct order (according to order of months in year)?

My dataframe:
Your month column is really a partial date (i.e. the year is missing), but you could still just convert that column to a proper date format and then sort.
You will have to specify a format, so the parser knows roughly what to do. 

df["date"] = pd.to_datetime(["20-Apr"], format="%d-%b")
df.sort_values("date")   # ascending by default


Without any year information, it will add the year as 1900.



If you want to add e.g. this year, you could do the following, adding 12*20 months to the new date column:

df["fixed_date"] = df.date.apply(lambda x: pd.tseries.offsets.shift_month(x, 12*20))