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

PERF: Remove Polars PerformanceWarning #1418

Merged
merged 2 commits into from
Sep 25, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions hvplot/plotting/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1875,18 +1875,22 @@ 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)):
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 params.get('hover_cols') == 'all':
columns = list(self._data.columns)
columns = column_names
else:
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
hoxbro marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -1897,7 +1901,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
Loading