holoviz / holoviz/hvplot

Cannot create plotly histogram from datetime data

Open
#1,001 0 comments 0 reactions 0 assignees View on GitHub
TRIAGE
Dominant language
Python
Stars
1.4k
Forks
124
Avg merge
1d 18h
Merged PRs (30d)
1

Description

hvplot==0.8.2

Motivated by #998 I'm trying to improve the `hist` reference guide.

When I try to create a `hist` plot from a datetime column it works fine as long as I use the `matplotlib` or `bokeh` backends. When I start using the `plotly` backend it raises an exception.

```python
import pandas as pd
from bokeh.sampledata.commits import data
import hvplot.pandas
backend = "plotly"
hvplot.extension(backend)

data=data.reset_index().sort_values("datetime")
plot = data.hvplot.hist(
"datetime",
bin_range=(pd.Timestamp('2012-11-30'), pd.Timestamp('2017-05-01')),
bins=54,
)

import holoviews as hv
hv.render(plot, backend)
```

```bash
$ python script.py
Traceback (most recent call last):
File "C:\repos\private\tmp\holoviews\script.py", line 15, in
hv.render(plot, backend)
File "C:\repos\private\tmp\holoviews\holoviews\util\__init__.py", line 829, in render
return renderer_obj.get_plot_state(obj)
File "C:\repos\private\tmp\holoviews\holoviews\plotting\plotly\renderer.py", line 86, in get_plot_state
fig_dict = go.Figure(fig_dict).to_dict()
File "C:\repos\private\hvplot\.venv\lib\site-packages\plotly\graph_objs\_figure.py", line 616, in __init__
super(Figure, self).__init__(data, layout, frames, skip_invalid, **kwargs)
File "C:\repos\private\hvplot\.venv\lib\site-packages\plotly\basedatatypes.py", line 514, in __init__
data = self._data_validator.validate_coerce(
File "C:\repos\private\hvplot\.venv\lib\site-packages\_plotly_utils\basevalidators.py", line 2668, in validate_coerce
trace = self.get_trace_class(trace_type)(
File "C:\repos\private\hvplot\.venv\lib\site-packages\plotly\graph_objs\_bar.py", line 3199, in __init__
self["width"] = _v
File "C:\repos\private\hvplot\.venv\lib\site-packages\plotly\basedatatypes.py", line 4859, in __setitem__
self._set_prop(prop, value)
File "C:\repos\private\hvplot\.venv\lib\site-packages\plotly\basedatatypes.py", line 5198, in _set_prop
val = validator.validate_coerce(val)
File "C:\repos\private\hvplot\.venv\lib\site-packages\_plotly_utils\basevalidators.py", line 803, in validate_coerce
if not (self.min_val <= v <= self.max_val):
TypeError: The DType could not be promoted by . This means that no common DType exists for the given inputs. For example they cannot be stored
in a single array unless the dtype is `object`. The full list of DTypes is: (, )
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.