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

Support faster processing using pandas or polars functions in IterableDataset.map() #7370

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

lhoestq
Copy link
Member

@lhoestq lhoestq commented Jan 14, 2025

Allow super fast processing using pandas or polars functions in IterableDataset.map() by adding support to pandas and polars formatting in IterableDataset

import polars as pl
from datasets import Dataset

ds = Dataset.from_dict({"i": range(10)}).to_iterable_dataset()
ds = ds.with_format("polars")
ds = ds.map(lambda df: df.with_columns(pl.col("i"), pl.col("i").add(1).alias("i+1")), batched=True)
ds = ds.with_format(None)
print(next(iter(ds)))
# {'i': 0, 'i+1': 1}

It leverages arrow's zero-copy features from/to pandas and polars.

related to #3444 #6762

@lhoestq lhoestq changed the title Add pandas and polars formatting in iterabledataset Add pandas and polars formatting in IterableDataset Jan 14, 2025
@lhoestq lhoestq changed the title Add pandas and polars formatting in IterableDataset Allow blazing fast processing using pandas or polars functions in IterableDataset.map() Jan 14, 2025
@lhoestq lhoestq changed the title Allow blazing fast processing using pandas or polars functions in IterableDataset.map() Support faster processing using pandas or polars functions in IterableDataset.map() Jan 14, 2025
@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

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.

2 participants