簡體   English   中英

如何在Pandas中按日期對此輸出進行排序

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

我有一個日期字段Datetime,我想要一個簡單的項目計數,但我喜歡它的日期順序..我現在有...

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

應該很簡單但不適合我......

正如安迪指出的那樣(上面是+ TomAugspurger)這是正確的解決方案:

plot_data.Quradate.value_counts().sort_index()

丑陋,但完成工作希望看到更好的解決方案。

resp=pd.DataFrame(plot_data.Quradate.value_counts()) # of respondents by survey date
resp.sort_index() 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM