From e1c5819564c232206abaccfd633a7d10dcc4808e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20H=C3=B8xbro=20Hansen?= Date: Wed, 8 May 2024 15:47:35 +0200 Subject: [PATCH 1/2] Add simple polars explorer --- hvplot/plotting/core.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/hvplot/plotting/core.py b/hvplot/plotting/core.py index c20dffdd4..3522df345 100644 --- a/hvplot/plotting/core.py +++ b/hvplot/plotting/core.py @@ -1909,6 +1909,19 @@ def _get_converter(self, x=None, y=None, kind=None, **kwds): return HoloViewsConverter(data, x, y, kind=kind, **params) + def explorer(self, x=None, y=None, **kwds): + import polars as pl + from ..ui import explorer as ui_explorer + + if isinstance(self._data, (pl.DataFrame, pl.Series)): + data = self._data.to_pandas() + elif isinstance(self._data, pl.LazyFrame): + data = self._data.collect().to_pandas() + else: + raise ValueError('Only Polars DataFrame, Series, and LazyFrame are supported') + + return ui_explorer(data, x=x, y=y, **kwds) + class hvPlot(hvPlotTabular): """ From 23d9f0c358464d12e15ed52cbeb7596c2e378b00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20H=C3=B8xbro=20Hansen?= Date: Wed, 8 May 2024 16:09:42 +0200 Subject: [PATCH 2/2] Update ylim calculation to not fail if object dtype is passed in. --- hvplot/ui.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hvplot/ui.py b/hvplot/ui.py index ee6f260b0..5fa40eebb 100644 --- a/hvplot/ui.py +++ b/hvplot/ui.py @@ -1031,7 +1031,9 @@ def ylim(self): y = self._y if not isinstance(y, list): y = [y] - values = [ys for ys in (self._data[y] for y in y) if len(ys)] + values = [ + ys for ys in (self._data[y] for y in y) if len(ys) and ys.dtype.kind not in 'OSU' + ] if not len(values): return (np.nan, np.nan) return max_range([(np.nanmin(vs), np.nanmax(vs)) for vs in values])