I have a pandas.DataFrame df with that contains the following series:
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
I would like to plot a histogram of the timedeltas. However:
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'
The following works:
hist(df.Time.astype('timedelta64[h]'))
You can use different units in the astype argument. Here I use ´h´ hours.
More detailed description can be found here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With