-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
[BUG] Reading multiindex, incorrectly names columns without name. #13115
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
Conversation
pls replicate the exact test as indicated in the issue (write it then read it). you don't need to include actual excel files unless you are trying to read something which pandas is not capable of generating (which I don't think is the case here). |
Ok, I have joined the tests. But the problem with Unnamed_columns remains, the code now explicitly checks if the cell is empty and if yes - it renames it to Is there any suggestion how to deal with this? |
so if you have something unnamed, you can do it like the
|
700673a
to
f4669f1
Compare
Current coverage is 84.14%@@ master #13115 diff @@
==========================================
Files 138 137 -1
Lines 50739 50288 -451
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
- Hits 42740 42312 -428
+ Misses 7999 7976 -23
Partials 0 0
|
So then everything should be OK. |
can you also add a test where the currently last column |
def _fill_mi_header(row): | ||
# forward fill blanks entries | ||
def _fill_mi_header(row, control_row): | ||
# forward fill blanks entries, but only inside same parent index |
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.
add a doc-string here
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.
Done.
11d59af
to
41874af
Compare
The new test is there and also the docstring. |
lgtm. @jorisvandenbossche |
@@ -1277,29 +1277,27 @@ def _write_hierarchical_rows(self, fmt_values, indent): | |||
|
|||
|
|||
def _get_level_lengths(levels, sentinel=''): |
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.
While you have rewritten this function a bit, would you like to add a docstring at once as well?
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.
@brandys11 ok, if you can update this doc-string. ping on green. ty.
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.
@jreback ping, everything is green
Minor comment (not essential for merging), looks good for the rest! |
41874af
to
c4b793b
Compare
Merge tests Fix flake8 issues. Fix tests with python 2.7 Add test with empty cell not at the end. Docstring for function _fill_mi_header Docstring for function _get_level_lengths
c4b793b
to
7953aee
Compare
thanks @brandys11 |
git diff upstream/master | flake8 --diff
Fixed reading and writing of Multiindex.
In a situation where Multiindex looked like this:
it was changed to: