From 25e22776fdde7d8b440110b7d0f0c4984b35ca7f Mon Sep 17 00:00:00 2001 From: MarcoGorelli <33491632+MarcoGorelli@users.noreply.github.com> Date: Mon, 18 Dec 2023 08:28:31 +0000 Subject: [PATCH 1/2] support polars in hvplot.plot method --- hvplot/plotting/__init__.py | 5 ++++- hvplot/util.py | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/hvplot/plotting/__init__.py b/hvplot/plotting/__init__.py index bd617de54..68e6f9c53 100644 --- a/hvplot/plotting/__init__.py +++ b/hvplot/plotting/__init__.py @@ -1,5 +1,5 @@ import holoviews as hv -from ..util import with_hv_extension +from ..util import with_hv_extension, is_polars from .core import hvPlot, hvPlotTabular # noqa @@ -30,6 +30,9 @@ def plot(data, kind, **kwargs): if v is not None: no_none_kwargs[k] = v + if is_polars(data): + from hvplot.polars import hvPlotTabularPolars + return hvPlotTabularPolars(data)(kind=kind, **no_none_kwargs) return hvPlotTabular(data)(kind=kind, **no_none_kwargs) diff --git a/hvplot/util.py b/hvplot/util.py index 6983ffd7d..de559f3f1 100644 --- a/hvplot/util.py +++ b/hvplot/util.py @@ -348,6 +348,12 @@ def is_dask(data): import dask.dataframe as dd return isinstance(data, (dd.DataFrame, dd.Series)) +def is_polars(data): + if not check_library(data, 'polars'): + return False + import polars as pl + return isinstance(data, (pl.DataFrame, pl.Series)) + def is_intake(data): if "intake" not in sys.modules: return False From ede06f90c5bad3810fa2c21cf61c6098fff5601f Mon Sep 17 00:00:00 2001 From: Marco Edward Gorelli Date: Mon, 18 Dec 2023 12:19:47 +0000 Subject: [PATCH 2/2] Update hvplot/util.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Simon Høxbro Hansen --- hvplot/util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hvplot/util.py b/hvplot/util.py index de559f3f1..49d0ef4a3 100644 --- a/hvplot/util.py +++ b/hvplot/util.py @@ -352,7 +352,7 @@ def is_polars(data): if not check_library(data, 'polars'): return False import polars as pl - return isinstance(data, (pl.DataFrame, pl.Series)) + return isinstance(data, (pl.DataFrame, pl.Series, pl.LazyFrame)) def is_intake(data): if "intake" not in sys.modules: