-
-
Notifications
You must be signed in to change notification settings - Fork 18k
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 to_latex() when using MultiIndex with NaN in (#14249) (v2) #20797
BUG: fix to_latex() when using MultiIndex with NaN in (#14249) (v2) #20797
Conversation
Refactor multiindex handling
Codecov Report
@@ Coverage Diff @@
## master #20797 +/- ##
==========================================
- Coverage 91.85% 91.77% -0.08%
==========================================
Files 153 153
Lines 49310 49257 -53
==========================================
- Hits 45292 45207 -85
- Misses 4018 4050 +32
Continue to review full report at Codecov.
|
The patch looks good, and thanks for investigating the related issues. If you could also add tests for them too, it would be great. |
lgtm. @toobaz merge when satisfied. |
@tomneep I just found out this PR fixes #18669 too: the original testcase cannot be reproduced (because of #18882 ), but the following can: In [2]: mi = pd.MultiIndex.from_product([[1, 2]])
In [3]: df = pd.DataFrame(-1, index=mi, columns=range(4))
In [4]: df.index.names = ['']
In [5]: print(df.to_latex())
\begin{tabular}{lrrrr}
\toprule
& 0 & 1 & 2 & 3 \\
\midrule
1 & & & & \\
2 & -1 & -1 & -1 & -1 \\
\bottomrule
\end{tabular} Would you mind adding a test/whatsnew mention for this? Then I think we're ready to go. |
@tomneep thanks! |
This is an improved version of #19910 cleaning up MultiIndex handling in the process.
git diff upstream/master -u -- "*.py" | flake8 --diff
I quickly looked at some other issues that this didn't originally aim to address and found that this PR closes #19981 and #18326 too, but I didn't add a tests or whats new entries for those (yet).Edit: tests and whatsnew entries added for: