Skip to content

Commit

Permalink
Remove polars performance warning
Browse files Browse the repository at this point in the history
  • Loading branch information
hoxbro committed Sep 23, 2024
1 parent efeda78 commit 1aad1ff
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions hvplot/plotting/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand Down

0 comments on commit 1aad1ff

Please sign in to comment.