Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

hoxbro
Copy link
Member

@hoxbro hoxbro commented Apr 24, 2025

Still very much draft... A lot of the logic is currently copied/pasted from the PandasInterface.

import polars as pl
import pyarrow as pa

import holoviews as hv

hv.extension("bokeh", "matplotlib", "plotly")

data = {"a": [1, 2, 3], "b": [4, 5, 6]}
df_pandas = pd.DataFrame(data)
df_polars = pl.DataFrame(data)
table_pa = pa.table(data)

layout = hv.Curve(df_polars) + hv.Scatter(table_pa)
layout

image

Copy link

codecov bot commented Apr 28, 2025

Codecov Report

❌ Patch coverage is 90.77527% with 94 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.08%. Comparing base (2da5bac) to head (e6f0ce5).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
holoviews/core/data/narwhals.py 84.57% 62 Missing ⚠️
...oloviews/tests/core/data/test_narwhalsinterface.py 92.92% 15 Missing ⚠️
holoviews/tests/core/data/test_cudfinterface.py 30.00% 7 Missing ⚠️
holoviews/util/transform.py 72.72% 3 Missing ⚠️
holoviews/core/data/cudf.py 50.00% 1 Missing ⚠️
holoviews/core/data/dictionary.py 50.00% 1 Missing ⚠️
holoviews/core/util/__init__.py 96.96% 1 Missing ⚠️
holoviews/operation/datashader.py 93.75% 1 Missing ⚠️
holoviews/operation/element.py 87.50% 1 Missing ⚠️
holoviews/plotting/bokeh/graphs.py 88.88% 1 Missing ⚠️
... and 1 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6567      +/-   ##
==========================================
+ Coverage   89.03%   89.08%   +0.04%     
==========================================
  Files         329      331       +2     
  Lines       70455    71213     +758     
==========================================
+ Hits        62728    63437     +709     
- Misses       7727     7776      +49     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.


# Handle selection dim expression
if selection_expr is not None:
if selection_expr is not None and selection_expr.ops:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would also make something like hv.Dataset(df_pandas).select(selection_expr=hv.dim('a')) fail

Comment on lines 41 to 43
datatypes = ['dataframe', 'dictionary', 'grid', 'xarray', 'multitabular',
'spatialpandas', 'dask_spatialpandas', 'dask', 'cuDF', 'array',
'spatialpandas', 'dask_spatialpandas', 'dask', 'cuDF', 'array', 'narwhals',
'ibis']
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Open for updating the position here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Position seems fine, though question is at what point we deprecate dask and cuDF interfaces (if ever).

@hoxbro hoxbro marked this pull request as ready for review September 3, 2025 16:33
@hoxbro
Copy link
Member Author

hoxbro commented Sep 3, 2025

I think this PR is in a good state. Likely, there are some rough edges, but don’t think that should stop a review/merge.

@hoxbro hoxbro requested a review from philippjfr September 3, 2025 17:56
if isinstance(df, (nw.DataFrame, nw.LazyFrame)):
df = df.select(list(map(str, kdims + vdims)))
if isinstance(df, nw.LazyFrame):
df = df.collect()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which LazyFrame types does narwhals support these days? Can we check if it's backed by a dask dataframe and avoid collect for that case?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup you can do if df.implementation.is_dask():

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have done this in 2c6388e

return data.collect()[dim.name]
else:
return data # Cannot slice LazyFrame
return data[dim.name]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the return type here, e.g. pandas this would be a pd.Series if keep_index else np.ndarray?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will return a nw.Series, except if compute is False, then a LazyFrame input will return a single-column LazyFrame.

"""
if issubclass(dataset.interface, NarwhalsInterface):
return dataset.data
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely a considerable broadening of our definition of DataFrame.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to force it to pandas? Or should we try this out for now and enable it if we see too many problems with it?

@maximlt
Copy link
Member

maximlt commented Sep 4, 2025

What is the plan for documenting this?

@hoxbro
Copy link
Member Author

hoxbro commented Sep 9, 2025

What is the plan for documenting this?

I don't think there should be many documentation updates for this, other than the updates I pushed in 4c80fdb.

We should definitely highlight that this is now supported in the release notes and other announcements.

@philippjfr philippjfr merged commit 1a7c936 into main Sep 29, 2025
14 checks passed
@philippjfr philippjfr deleted the feat_narwhals branch September 29, 2025 09:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants