fix: set columns and dtype explicitly in dataset readers#1706
Open
ShresthSamyak wants to merge 1 commit into
Open
fix: set columns and dtype explicitly in dataset readers#1706ShresthSamyak wants to merge 1 commit into
ShresthSamyak wants to merge 1 commit into
Conversation
- docred_reader: replace generic d1-d4 column names with rel_id, train, valid, test - basic_classification_reader: add dtype to passthrough keys for csv and json reads Fixes deeppavlov#1654
There was a problem hiding this comment.
Pull request overview
This PR addresses issue #1654 by making dataset reader outputs more explicit and controllable, improving downstream schema readability and reducing silent type inference surprises.
Changes:
- Updated
DocREDDatasetReader.print_statistics()to use meaningful column names (rel_id,train,valid,test) instead of genericd1..d4. - Extended
BasicClassificationDatasetReaderto pass throughdtypetopandas.read_csv()andpandas.read_json()so callers can explicitly control column types.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
deeppavlov/dataset_readers/docred_reader.py |
Renames statistics DataFrame columns to explicit, semantically meaningful names for clearer logging/output. |
deeppavlov/dataset_readers/basic_classification_reader.py |
Adds dtype passthrough to pandas readers to allow explicit column type control. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
80
to
87
| if format == 'csv': | ||
| keys = ('sep', 'header', 'names') | ||
| keys = ('sep', 'header', 'names', 'dtype') | ||
| options = {k: kwargs[k] for k in keys if k in kwargs} | ||
| df = pd.read_csv(file, **options) | ||
| elif format == 'json': | ||
| keys = ('orient', 'lines') | ||
| keys = ('orient', 'lines', 'dtype') | ||
| options = {k: kwargs[k] for k in keys if k in kwargs} | ||
| df = pd.read_json(file, **options) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1654
Changes
control column types
Code smell addressed
Columns and DataType Not Explicitly Set — Zhang et al., CAIN 2022