Skip to content

BUG: read_csv not respecting converter in all cases for index col #46053

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

Merged
merged 3 commits into from
Feb 26, 2022

Conversation

phofl
Copy link
Member

@phofl phofl commented Feb 18, 2022

@phofl phofl added the IO CSV read_csv, to_csv label Feb 18, 2022
@@ -503,7 +505,11 @@ def _agg_index(self, index, try_parse_dates: bool = True) -> Index:
if isinstance(clean_dtypes, dict) and self.index_names is not None:
cast_type = clean_dtypes.get(self.index_names[i], None)

try_num_bool = not (cast_type and is_string_dtype(cast_type))
conv = False
if isinstance(converters, dict) and self.index_names is not None:
Copy link
Member

Choose a reason for hiding this comment

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

Could combine with the above check as if self.index_names is not None: first and then the 2 isinstance(arg, dict) checks

Copy link
Member Author

Choose a reason for hiding this comment

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

Thx, this looks better, also renamed the variable

@mroeschke mroeschke added this to the 1.5 milestone Feb 22, 2022
Copy link
Member

@mroeschke mroeschke left a comment

Choose a reason for hiding this comment

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

LGTM

@jreback jreback merged commit 7ee8ab0 into pandas-dev:main Feb 26, 2022
@jreback
Copy link
Contributor

jreback commented Feb 26, 2022

very nice @phofl

@phofl phofl deleted the 40589 branch June 6, 2022 20:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
IO CSV read_csv, to_csv
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: converters of dtype is ignored in read_csv if related to index column
3 participants