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

[feat] add from_parquet to dataloader #709

Merged

Conversation

JamesHWade
Copy link
Contributor

A parquet file loader would be a convenient addition to the dataloader class. I particularly like that parquet files preserve types better than a csv file.

Here's the change:

def from_parquet(self, file_path: str, fields: list[str] = None, input_keys: tuple[str] = ()) -> list[dspy.Example]:
        dataset = load_dataset("parquet", data_files=file_path)["train"]

        if not fields:
            fields = list(dataset.features)

        return [dspy.Example({field: row[field] for field in fields}).with_inputs(input_keys) for row in dataset]

Note, this PR was originally made in #483, but something with git hooks prevented test from being able to run.

@arnavsinghvi11 arnavsinghvi11 merged commit a8b6e40 into stanfordnlp:main Mar 25, 2024
4 checks passed
@arnavsinghvi11
Copy link
Collaborator

Thanks @JamesHWade !

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