-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Fix of handle missing CSV MI column names #23484
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
BUG: Fix of handle missing CSV MI column names #23484
Conversation
Hello @gfyoung! Thanks for submitting the PR.
|
41ef255
to
2668351
Compare
Codecov Report
@@ Coverage Diff @@
## master #23484 +/- ##
==========================================
+ Coverage 92.23% 92.23% +<.01%
==========================================
Files 161 161
Lines 51197 51204 +7
==========================================
+ Hits 47220 47227 +7
Misses 3977 3977
Continue to review full report at Codecov.
|
Before, only the first index name got replaced with `None` so long as it had the string "Unnamed" in it. Now we replace all index names with `None` if they were deliberately set with placeholders.
2668351
to
e18fef9
Compare
@jreback : I simplified the logic a little bit, but I still needed |
@@ -786,6 +793,9 @@ cdef class TextReader: | |||
name = '%s.%d' % (name, count) | |||
count = counts.get(name, 0) | |||
|
|||
if old_name == '': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems like you could just add unamed_cols.add(name)
at line 774 (e.g. after the if name == ''
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not quite. You need to add the name that you get post-mangling (e.g. if there are dupes). That's why you have to "keep track" after the logic ending at 794.
thanks! |
De-hackifies this hack:
pandas/pandas/io/parsers.py
Lines 3206 to 3211 in d78bd7a
Setup:
Before:
After: