【发布时间】:2018-04-07 20:00:29
【问题描述】:
我有日期从 1970 年到 2018 年的数据框,我想绘制从 2016 年到 2017 年的发生频率。
In[95]: df['last_payout'].dtypes
Out[95]: dtype('<M8[ns]')
数据以这种格式存储:
In[96]: df['last_payout'].head
Out[96]: <bound method NDFrame.head of 0 1970-01-01
1 1970-01-01
2 1970-01-01
3 1970-01-01
4 1970-01-01
我使用 group by 和 count 按年份绘制:
In[97]: df['last_payout'].groupby(df['last_payout'].dt.year).count().plot(kind="bar")
我想在特定日期之间获取此图,我尝试输入df['last_payout'].dt.year > 2016,但我得到了这个:
如何获取特定日期范围的图?
【问题讨论】: