While trying to plot timedate gaps using the Matplotlib broken_barh API I get an error:
--> 538 return array(a, dtype, copy=False, order=order)
539
540
ValueError: Could not convert object to NumPy datetime
I am using Jupiter notebook in Windows 10 Pro 64bits with Python 3.6.1
My pandas DataFrame is:
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 266 entries, 0 to 265
Data columns (total 9 columns):
End Seq 266 non-null int64
End Time 266 non-null datetime64[ns]
Gap Seq 266 non-null int64
Gap Time 266 non-null float64
Source 266 non-null object
Start Seq 266 non-null int64
Start Time 266 non-null datetime64[ns]
Target 266 non-null object
Gap Time (s) 266 non-null timedelta64[ns]
dtypes: datetime64[ns](2), float64(1), int64(3), object(2),
timedelta64[ns](1)
memory usage: 18.8+ KB
I have googled a lot and have not been able to find any reasonable explanation as to why this is not working.
This is the code I am using in my jupyter notebook:
fig, ax = plt.subplots()
ax.broken_barh(list(zip(df['Start Time'].values, (df['Gap Time
(s)']).values)), (0, 0.5))
ax.set_ylim(-2,2)
plt.show()
My expectation as to have jupyter display a barh graph like:
https://matplotlib.org/devdocs/gallery/lines_bars_and_markers/broken_barh.html