Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get this output to sort by date in Pandas

Tags:

python

pandas

I have a date field Datetime and I want a simple count of the items but i's like it in date order.. what I have now...

plot_data.Quradate.value_counts() # of respondents by survey date
2011-07-15    702
2011-04-15    696
2011-10-15    661
2010-01-15    636
2011-01-15    587
2010-10-15    570
2012-01-15    534
2010-07-15    525
2010-04-15    384
dtype: int64

Should be simple but not yet for me...

like image 614
dartdog Avatar asked Oct 24 '13 16:10

dartdog


1 Answers

As Andy points out And (+TomAugspurger above) this is the right solution:

plot_data.Quradate.value_counts().sort_index()

Ugly, but gets the job done would like to see a better solution.

resp=pd.DataFrame(plot_data.Quradate.value_counts()) # of respondents by survey date
resp.sort_index() 
like image 85
dartdog Avatar answered Sep 23 '22 17:09

dartdog