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

Add simple polars support #1129

Merged
merged 14 commits into from
Oct 2, 2023
Merged

Add simple polars support #1129

merged 14 commits into from
Oct 2, 2023

Conversation

hoxbro
Copy link
Member

@hoxbro hoxbro commented Aug 28, 2023

resolves #1023

This adds a simple Polars support to hvplot by converting it to a Pandas DataFrame before putting it into the machinery of hvplot. I'm trying to convert only the necessary columns for the DataFrame and LazyDataFrame.

Using the API as described here.

import hvplot.polars  # noqa
import polars as pl
from bokeh.sampledata.autompg import autompg

df = pl.DataFrame(autompg)
s = df.select("mpg").to_series()
ldf = df.lazy()

type(df), type(s), type(ldf)

df.hvplot(y="cyl")
s.hvplot()
ldf.hvplot.scatter()

image

@hoxbro hoxbro marked this pull request as draft August 29, 2023 18:11
@itsgifnotjiff
Copy link

Thank you so much Mr. @hoxbro . What do you mean by simple? Is there something that a Pandas DataFrame backed HvPlot/Holoviews object can fundementally do that a Polars one can not?

@philippjfr
Copy link
Member

What do you mean by simple? Is there something that a Pandas DataFrame backed HvPlot/Holoviews object can fundementally do that a Polars one can not?

This PR simply converts the data to a pandas DataFrame before passing it to the existing codepaths. The longer term and more efficient approach will be to implement a data backend for HoloViews that natively understands and works with polars dataframes, avoiding any copies that occur in the polars -> pandas conversion and potentially executing specific computations, e.g. histograms, aggregations etc., directly with polars.

@itsgifnotjiff
Copy link

Thank you Mr. @philippjfr . I have a Panel app that uses Polars to load 12 GB SQLite and cast it to a Pandas DataFrame and I always wondered how it would perform using Polars alone.

@hoxbro hoxbro marked this pull request as ready for review September 7, 2023 10:00
@maximlt maximlt added this to the 0.9.0 milestone Sep 11, 2023
Copy link
Member

@maximlt maximlt left a comment

Choose a reason for hiding this comment

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

Except a few minor changes this looks good to me. This is going to make polars users very happy! I wish we had a place where to expose that more in the docs, the front-page isn't the best place.

Note to self, the release notes should mention that this is basic support and the data is casted to Pandas objects. By the way @hoxbro Series don't need to be casted?

hvplot/polars.py Show resolved Hide resolved
hvplot/polars.py Outdated Show resolved Hide resolved
hvplot/polars.py Outdated Show resolved Hide resolved
hvplot/tests/plotting/testcore.py Show resolved Hide resolved
setup.py Show resolved Hide resolved
hoxbro and others added 2 commits September 29, 2023 08:54
Co-authored-by: Maxime Liquet <35924738+maximlt@users.noreply.github.com>
hvplot/polars.py Outdated Show resolved Hide resolved
hoxbro and others added 2 commits October 2, 2023 11:58
Co-authored-by: Maxime Liquet <35924738+maximlt@users.noreply.github.com>
@maximlt maximlt merged commit 4e9436d into main Oct 2, 2023
7 checks passed
@maximlt maximlt deleted the polars_support_simple branch October 2, 2023 14:34
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.

polars support
4 participants