From 1aad1ff144b5d4d145e84c0765d9615ca096f784 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20H=C3=B8xbro=20Hansen?= Date: Mon, 23 Sep 2024 14:27:59 +0200 Subject: [PATCH] Remove polars performance warning --- hvplot/plotting/core.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/hvplot/plotting/core.py b/hvplot/plotting/core.py index 25defa6e9..fb9041406 100644 --- a/hvplot/plotting/core.py +++ b/hvplot/plotting/core.py @@ -1875,18 +1875,20 @@ def _get_converter(self, x=None, y=None, kind=None, **kwds): # Find columns which should be converted for LazyDataFrame and DataFrame if isinstance(self._data, (pl.LazyFrame, pl.DataFrame)): - if params.get('hover_cols') == 'all': - columns = list(self._data.columns) - else: + try: + column_names = self._data.collect_schema().names() + except Exception: # Maybe not always supported, has been there since 1.7.1 + column_names = list(self._data.columns) + + if not params.get('hover_cols') == 'all': possible_columns = [ [v] if isinstance(v, str) else v for v in params.values() if isinstance(v, (str, list)) ] - columns = (set(self._data.columns) & set(itertools.chain(*possible_columns))) or { - self._data.columns[0] - } + columns = set(column_names) & set(itertools.chain(*possible_columns)) + columns = columns or {column_names[0]} if y is None: # When y is not specified HoloViewsConverter finds all the numeric # columns and use them as y values (see _process_chart_y). We meed @@ -1897,7 +1899,7 @@ def _get_converter(self, x=None, y=None, kind=None, **kwds): columns |= {*xs, *ys} columns.discard(None) # Reorder the columns as in the data. - columns = sorted(columns, key=lambda c: self._data.columns.index(c)) + columns = sorted(columns, key=lambda c: column_names.index(c)) if isinstance(self._data, pl.DataFrame): data = self._data.select(columns).to_pandas()