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

Specify columns when reading files with DocumentDataset #311

Merged
merged 4 commits into from
Oct 22, 2024

Conversation

sarahyurick
Copy link
Collaborator

Closes #180.

All of these will now work:

(1) Pandas and cuDF read_json do not support a columns parameter, so we read in the entire DataFrame and then remove unwanted columns behind the scenes.

dataset = DocumentDataset.read_json(dataset_path, columns=["col1", "col2"])

(2) Pandas and cuDF read_parquet both support a columns parameter, so we are able to take advantage of this functionality.

dataset = DocumentDataset.read_parquet(dataset_path, columns=["col1", "col2"])

(3) Pandas read_pickle (there is no cuDF read_pickle) does not support a columns parameter, so we read in the entire DataFrame and then remove unwanted columns behind the scenes.

dataset = DocumentDataset.read_pickle(dataset_path, columns=["col1", "col2"])

(4) Following cudf.read_json, you can specify dtype and prune_columns=True to only return the columns mentioned in the dtype argument. Note that Pandas does not support prune_columns.

dataset = DocumentDataset.read_json(
    dataset_path,
    dtype={"col1": str, "col2": str},
    prune_columns=True,
    backend="cudf",
)

Signed-off-by: Sarah Yurick <[email protected]>
Signed-off-by: Sarah Yurick <[email protected]>
@sarahyurick sarahyurick requested a review from ryantwolf October 18, 2024 20:05
Signed-off-by: Sarah Yurick <[email protected]>
Copy link
Collaborator

@ryantwolf ryantwolf left a comment

Choose a reason for hiding this comment

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

One minor thing, then we should be good.

Signed-off-by: Sarah Yurick <[email protected]>
@sarahyurick sarahyurick requested a review from ryantwolf October 21, 2024 21:54
Copy link
Collaborator

@ryantwolf ryantwolf left a comment

Choose a reason for hiding this comment

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

Good with me, thanks!

@sarahyurick sarahyurick merged commit dc87963 into NVIDIA:main Oct 22, 2024
3 checks passed
@sarahyurick sarahyurick deleted the read_columns branch October 25, 2024 20:44
VibhuJawa pushed a commit to VibhuJawa/NeMo-Curator that referenced this pull request Oct 29, 2024
* add column param

Signed-off-by: Sarah Yurick <[email protected]>

* read_pickle and black

Signed-off-by: Sarah Yurick <[email protected]>

* optional param

Signed-off-by: Sarah Yurick <[email protected]>

* add parquet comment

Signed-off-by: Sarah Yurick <[email protected]>

---------

Signed-off-by: Sarah Yurick <[email protected]>
ayushdg pushed a commit to ayushdg/NeMo-Curator that referenced this pull request Oct 30, 2024
* add column param

Signed-off-by: Sarah Yurick <[email protected]>

* read_pickle and black

Signed-off-by: Sarah Yurick <[email protected]>

* optional param

Signed-off-by: Sarah Yurick <[email protected]>

* add parquet comment

Signed-off-by: Sarah Yurick <[email protected]>

---------

Signed-off-by: Sarah Yurick <[email protected]>
Signed-off-by: Ayush Dattagupta <[email protected]>
vinay-raman pushed a commit to vinay-raman/NeMo-Curator that referenced this pull request Nov 26, 2024
* add column param

Signed-off-by: Sarah Yurick <[email protected]>

* read_pickle and black

Signed-off-by: Sarah Yurick <[email protected]>

* optional param

Signed-off-by: Sarah Yurick <[email protected]>

* add parquet comment

Signed-off-by: Sarah Yurick <[email protected]>

---------

Signed-off-by: Sarah Yurick <[email protected]>
Signed-off-by: Vinay Raman <[email protected]>
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.

[FEA] Allow specify fields when reading files with DocumentDataset.
3 participants