`holoviews.element. Curve` does not accept pandas data frame where index is `TimedeltaIndex`
See original GitHub issueThe following code works as expected:
import pandas as pd
import holoviews as hv
hv.extension('bokeh', 'matplotlib')
import numpy as np
dt = pd.date_range('2018-02-23T12:34:45', '2018-02-23T12:47:00', freq='1s', name='t')
data = pd.DataFrame(np.sin((dt-dt[0]) / np.timedelta64(1,'m')).values, columns=('A', ), index=dt)
hv.Curve(data)
but
data.index = dt - dt[0]
hv.Curve(data)
raises an error:
TypeError: ufunc 'isfinite' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
I would like to plot pandas data frames indexed both by DatetimeIndex
(works) or TimedeltaIndex
(does not work)
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
holoviews.element. Curve does not accept pandas data frame ...
Curve does not accept pandas data frame where index is TimedeltaIndex # ... import pandas as pd import holoviews as hv hv.extension('bokeh', ...
Read more >Holoviews Table does not visually preserves index
1) You could set the index as your key dimension: hv.Table(statdf, kdims=['index']). When using the bokeh backend this will still give you ...
Read more >Pandas Conversion - HoloViews
Let's start by constructing a Pandas dataframe of a few columns and display ... is not needed by HoloViews, the index of the...
Read more >ValueError: You must specify a period or x must be a pandas ...
Though it uses the time index (DatetimeIndex) for its x-axis, it does not require an item to hit the frequency exactly, in contrast...
Read more >param.depends watch=True not working Part2
I clicked the table , too . the graph axis has changed. ... np import pandas as pd import panel as pn import...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The formatting issues are subsumed by https://github.com/holoviz/holoviews/issues/3143 so I’ll close this now.
I’ve done some testing using my patched bokeh miccoli/bokeh@0545753. Starting from numpy
datetime64
andtimedelta64
types, I’ve created two different pandas data frames.Here the results of
hv.Curve(pddt)
andhv.Curve(pdtd)
The problem here is that in bokeh timedelta are scaled as ms (millisecond) and represented with a plain linear axis. This is could be OK, but the choice of ms is not very sensible in my opinion… Using the matplotlib backend one gets the same linear axis but with timedelta scaled as ns (nanosecond).
Things are not that better in pandas:
pdtd.plot(figsize=(14,3), grid=True)
Things to fix, in my opinion:
Of course the ideal solution would be to implement native timedelta support in bokeh (extending the datetime axis or maybe creating a new timedelta axis type.)