我接受了我的系列并将其强制转换为dtype =的日期时间列datetime64[ns](虽然只需要一天的分辨率......不确定如何更改).
import pandas as pd
df = pd.read_csv('somefile.csv')
column = df['date']
column = pd.to_datetime(column, coerce=True)
Run Code Online (Sandbox Code Playgroud)
但绘图不起作用:
ipdb> column.plot(kind='hist')
*** TypeError: ufunc add cannot use operands with types dtype('<M8[ns]') and dtype('float64')
Run Code Online (Sandbox Code Playgroud)
我想绘制一个直方图,只显示按周,月或年的日期计数.
当然有办法做到这一点pandas?