matplotlib,pandas,如何生成时间增量的直方图?

matplotlib,pandas,如何生成时间增量的直方图?,pandas,matplotlib,Pandas,Matplotlib,我有一个pandas.DataFramedf,其中包含以下系列: Time 2182447 0 days 05:44:00 2182447 0 days 05:49:00 3129563 0 days 22:09:00 13341029 0 days 16:49:00 13341029 0 days 16:58:00 25622668 0 days 08:24:00 25622668 0 days 08:28:00 30077018 24 da

我有一个pandas.DataFrame
df
,其中包含以下系列:

Time
2182447     0 days 05:44:00
2182447     0 days 05:49:00
3129563     0 days 22:09:00
13341029    0 days 16:49:00
13341029    0 days 16:58:00
25622668    0 days 08:24:00
25622668    0 days 08:28:00
30077018   24 days 15:01:00
30077018   24 days 15:09:00
20131954    0 days 06:18:00
我想画一个时间增量的柱状图。然而:

hist(df)
df.Time.hist()
# both functions give the same error
>>> TypeError: Cannot cast ufunc less input from dtype('float64') to dtype('<m8[ns]') with casting rule 'same_kind'
hist(df)
df.Time.hist()
#两个函数都给出相同的错误
>>>TypeError:无法将ufunc-less输入从dtype('float64')转换为dtype('以下工作:

hist(df.Time.astype('timedelta64[h]'))
您可以在astype参数中使用不同的单位。这里我使用“h”小时