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

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

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 <sarahyurick@gmail.com>
Signed-off-by: Sarah Yurick <sarahyurick@gmail.com>
Signed-off-by: Sarah Yurick <sarahyurick@gmail.com>
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.
2 participants