DataFrame.hvplot fails with MultiIndex columns
- Dominant language
- Python
- Stars
- 1.4k
- Forks
- 124
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 1
Description
#### ALL software version info (hvPlot, holoviews, bokeh, python, notebook, OS, browser, any other relevant packages)
Selected packages from `conda env export`:
```
- bokeh=1.3.4=py37_0
- holoviews=1.12.6=py_0
- hvplot=0.5.2=py_0
- ipykernel=5.1.0=py37h39e3cac_0
- ipython=7.5.0=py37h39e3cac_0
- ipython_genutils=0.2.0=py37_0
- ipywidgets=7.4.2=py37_0
- jupyter_client=5.2.4=py37_0
- jupyter_core=4.4.0=py37_0
- jupyterlab=0.35.5=py37hf63ae98_0
- jupyterlab_server=0.2.0=py37_0
- matplotlib=3.0.3=py37h5429711_0
- numpy=1.16.3=py37h7e9f1db_0
- pandas=0.23.4=py37h04863e7_0
- python=3.7.3=h0371630_0
```
#### Description of expected behavior and the observed behavior
Calling `DataFrame.hvplot` with a DataFrame that has MultiIndex columns should work, similar to how `DataFrame.plot` does. Instead it raises a `TypeError`.
#### Complete, minimal, self-contained example code that reproduces the issue
```
import pandas as pd
import hvplot.pandas
df = pd.DataFrame([[1, 2], [3, 4]], columns=pd.MultiIndex.from_product([['a'], ['b', 'c']]))
df.plot() # works
df.hvplot() # raise TypeError
```
The traceback is:
```
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
in
----> 1 df.hvplot()
/var/local/conda/envs/devtools/lib/python3.7/site-packages/hvplot/plotting/core.py in __call__(self, x, y, kind, **kwds)
70 return pn.panel(plot, **panel_dict)
71
---> 72 return self._get_converter(x, y, kind, **kwds)(kind, x, y)
73
74 def _get_converter(self, x=None, y=None, kind=None, **kwds):
/var/local/conda/envs/devtools/lib/python3.7/site-packages/hvplot/converter.py in __call__(self, kind, x, y)
942 obj = DynamicMap(cbcallable, streams=[self.stream])
943 else:
--> 944 obj = method(x, y)
945
946 if self.crs and self.project:
/var/local/conda/envs/devtools/lib/python3.7/site-packages/hvplot/converter.py in line(self, x, y, data)
1228
1229 def line(self, x=None, y=None, data=None):
-> 1230 return self.chart(Curve, x, y, data)
1231
1232 def step(self, x=None, y=None, data=None):
/var/local/conda/envs/devtools/lib/python3.7/site-packages/hvplot/converter.py in chart(self, element, x, y, data)
1223 for c in y:
1224 kdims, vdims = self._get_dimensions([x], [c])
-> 1225 chart = element(data, kdims, vdims).redim(**{c: self.value_label})
1226 charts.append((c, chart.relabel(**self._relabel)))
1227 return self._by_type(charts, self.group_label, sort=False).opts(opts)
TypeError: __call__() keywords must be strings
```
Contributor guide
Assessment
This issue has not been assessed yet.