0

This might be a duplicate question but a simple answer and direct answer may help many,

I have a dataframe df which has following columns :

       months  knowledgebank  inventory  advisory  activities
0    november            415        431       517         506
1      august            285        346       225         226
2   september            383        411       365         381
3        june            589        532       526         559
4         may            695        651       557         624
5    february            467        339       340         453
6     january            821        501       744         711
7    december            554        432       640         384
8        july            484        503       422         494
9       april            512        390       422         500
10      march            360        387       267         403
11     october            462        233       200         322

I want to sort the months column from january to december

as:

     months  knowledgebank  inventory  advisory  activities
0   january            821        501       744         711
1   february           467        339       340         453
.       .
.       .  
.       .
11   december
KcH
  • 3,302
  • 3
  • 21
  • 46
  • 1
    This [answer](https://stackoverflow.com/a/48043319/9081267) answers your question – Erfan Aug 16 '19 at 11:15
  • The redirected answers were somewhat different to mine .......but thanks for the quick answer!! – KcH Aug 16 '19 at 11:19
  • 1
    Only difference is that you have to change `Jan` to `January`, `Feb` to `February` etc. – Erfan Aug 16 '19 at 11:21
  • yeah mate, I got it then....thanks – KcH Aug 16 '19 at 11:22
  • If some one needs the direct answer as one our mate mentioned and deleted: 1)import calendar 2)d={i.lower():e for e,i in enumerate(calendar.month_name)} 3)df=df.reindex(df.months.map(d).sort_values().index) – KcH Aug 16 '19 at 11:23
  • 1
    @Codenewbie yes, added the answer to the link in the dupe. Hence deleted it from here. – anky Aug 16 '19 at 11:39

0 Answers0