Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it easier to use hvplot.explorer with Polars #1339

Open
MarcSkovMadsen opened this issue May 8, 2024 · 0 comments · May be fixed by #1340
Open

Make it easier to use hvplot.explorer with Polars #1339

MarcSkovMadsen opened this issue May 8, 2024 · 0 comments · May be fixed by #1340
Labels
type: enhancement New feature or request

Comments

@MarcSkovMadsen
Copy link
Collaborator

MarcSkovMadsen commented May 8, 2024

As polars has the .plot method it would be obvious and very valuable that .plot.explorer() also worked. But it does not.

Run the below code in a notebook

import polars as pl

df = pl.read_csv("https://assets.holoviz.org/panel/tutorials/turbines.csv.gz")

df.plot.explorer()

See that it raises an exception.

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[3], line 5
      1 import polars as pl
      3 df = pl.read_csv("https://assets.holoviz.org/panel/tutorials/turbines.csv.gz")
----> 5 df.plot.explorer()

File /opt/conda/lib/python3.11/site-packages/hvplot/plotting/core.py:168, in hvPlotBase.explorer(self, x, y, **kwds)
    129 """
    130 The `explorer` plot allows you to interactively explore your data.
    131 
   (...)
    164     df.hvplot.explorer()
    165 """
    166 from ..ui import explorer as ui_explorer
--> 168 return ui_explorer(self._data, x=x, y=y, **kwds)

File /opt/conda/lib/python3.11/site-packages/hvplot/ui.py:87, in explorer(data, **kwargs)
     55 def explorer(data, **kwargs):
     56     """Explore your data and design your plot via an interactive user interface.
     57 
     58     This function returns an interactive Panel component that enable you to quickly change the
   (...)
     85     >>> hvplot.explorer(df, kind='bar', x='x')
     86     """
---> 87     return hvPlotExplorer.from_data(data, **kwargs)

File /opt/conda/lib/python3.11/site-packages/hvplot/ui.py:547, in hvPlotExplorer.from_data(cls, data, **params)
    545 else:
    546     cls = hvDataFrameExplorer
--> 547 return cls(data, **params)

File /opt/conda/lib/python3.11/site-packages/hvplot/ui.py:557, in hvPlotExplorer.__init__(self, df, **params)
    555     params['y_multi'] = params.pop('y') if isinstance(params['y'], list) else [params['y']]
    556 statusbar_params = {k: params.pop(k) for k in params.copy() if k in StatusBar.param}
--> 557 converter = _hvConverter(
    558     df, x, y, **{k: v for k, v in params.items() if k not in ('x', 'y', 'y_multi')}
    559 )
    560 # Collect kwargs passed to the constructor but meant for the controls
    561 extras = {k: params.pop(k) for k in params.copy() if k not in self.param}

File /opt/conda/lib/python3.11/site-packages/hvplot/converter.py:595, in HoloViewsConverter.__init__(self, data, x, y, kind, by, use_index, group_label, value_label, backlog, persist, use_dask, crs, fields, groupby, dynamic, grid, legend, rot, title, xlim, ylim, clim, robust, symmetric, logx, logy, loglog, hover, subplots, label, invert, stacked, colorbar, datashade, rasterize, downsample, resample_when, row, col, debug, framewise, aggregator, projection, global_extent, geo, precompute, flip_xaxis, flip_yaxis, dynspread, hover_cols, x_sampling, y_sampling, project, tools, attr_labels, coastline, tiles, tiles_opts, sort_date, check_symmetric_max, transforms, stream, cnorm, features, rescale_discrete_levels, autorange, **kwds)
    593 self.value_label = value_label
    594 self.label = label
--> 595 self._process_data(
    596     kind,
    597     data,
    598     x,
    599     y,
    600     by,
    601     groupby,
    602     row,
    603     col,
    604     use_dask,
    605     persist,
    606     backlog,
    607     label,
    608     group_label,
    609     value_label,
    610     hover_cols,
    611     attr_labels,
    612     transforms,
    613     stream,
    614     robust,
    615     kwds,
    616 )
    618 self.dynamic = dynamic
    619 self.geo = any([geo, crs, global_extent, projection, project, coastline, features])

File /opt/conda/lib/python3.11/site-packages/hvplot/converter.py:1157, in HoloViewsConverter._process_data(self, kind, data, x, y, by, groupby, row, col, use_dask, persist, backlog, label, group_label, value_label, hover_cols, attr_labels, transforms, stream, robust, kwds)
   1155     self.data = data
   1156 else:
-> 1157     raise ValueError('Supplied data type %s not understood' % type(data).__name__)
   1159 if stream is not None:
   1160     if streaming:

ValueError: Supplied data type DataFrame not understood

FYI. @MarcoGorelli

@hoxbro hoxbro linked a pull request May 8, 2024 that will close this issue
@maximlt maximlt added type: enhancement New feature or request and removed TRIAGE labels May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants