Sort a pandas's dataframe series by month name?

前端 未结 6 1727
无人及你
无人及你 2020-12-01 06:09

I have a Series object that has:

    date   price
    dec      12
    may      15
    apr      13
    ..

Problem statement:

6条回答
  •  攒了一身酷
    2020-12-01 06:42

    You should consider re-indexing it based on axis 0 (indexes)

    new_order = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
    
    df1 = df.reindex(new_order, axis=0)
    

提交回复
热议问题