-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: LatexFormatter.write_result multi-index #17499
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: LatexFormatter.write_result multi-index #17499
Conversation
04c2f82
to
cb6aa41
Compare
Codecov Report
@@ Coverage Diff @@
## master #17499 +/- ##
==========================================
- Coverage 91.18% 91.17% -0.02%
==========================================
Files 163 163
Lines 49543 49547 +4
==========================================
- Hits 45177 45172 -5
- Misses 4366 4375 +9
Continue to review full report at Codecov.
|
cb6aa41
to
f05f3b9
Compare
doc/source/whatsnew/v0.21.0.txt
Outdated
@@ -415,6 +415,7 @@ I/O | |||
- Bug in :func:`read_stata` where value labels could not be read when using an iterator (:issue:`16923`) | |||
- Bug in :func:`read_html` where import check fails when run in multiple threads (:issue:`16928`) | |||
- Bug in :func:`read_csv` where automatic delimiter detection caused a ``TypeError`` to be thrown when a bad line was encountered rather than the correct error message (:issue:`13374`) | |||
- Bug in ``LatexFormatter.write_result`` where repeated multi-index values were not printed even though a higher level index differed from the previous row (:issue:`14484`) |
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.
Reference the function that users will care about, which is "to_latex" instead of "LatexFormatter.write_result" . Also, follow the convention used in the two lines above when referencing "to_latex" with the func
notation.
@@ -221,6 +221,22 @@ def test_to_latex_multiindex(self): | |||
|
|||
assert result == expected | |||
|
|||
# GH 14484 |
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 more comments about what you're testing here.
f05f3b9
to
586adf8
Compare
@gfyoung Thanks for the comments, it is fixed and green again |
@@ -415,6 +415,7 @@ I/O | |||
- Bug in :func:`read_stata` where value labels could not be read when using an iterator (:issue:`16923`) | |||
- Bug in :func:`read_html` where import check fails when run in multiple threads (:issue:`16928`) | |||
- Bug in :func:`read_csv` where automatic delimiter detection caused a ``TypeError`` to be thrown when a bad line was encountered rather than the correct error message (:issue:`13374`) | |||
- Bug in :func:`to_latex` where repeated multi-index values were not printed even though a higher level index differed from the previous row (:issue:`14484`) |
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.
I think we might have to simplify this, but I'll see what @jreback thinks.
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.
Besides my comment about the whatsnew
(wait until @jreback comments), this looks good to go.
@@ -897,11 +897,19 @@ def get_col_type(dtype): | |||
lev3 = [blank] * clevels | |||
if name: | |||
lev3.append(lev.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.
I think it might be better to restructure this whole loop.
iterating like this:
for g, grp in table.groupby(level=0):
# grp is a DataFrame
would be simpler to print out I think.
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.
You are correct, using df.groupby makes it simpler. Change is implemented and I will ping you once it is green.
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.
I just had to revert my change. My attempt using df.groupby() changed the order of some elements and it didn't format more complex indicies like dates correctly.
The current approach does not have any of these issues, so I think it is the best I can do right now.
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.
ok, neither of these should be true, come back when you can
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.
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.
ok thanks
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.
e21d2f3
to
1291ead
Compare
Fixed GH issue 14484: `LatexFormatter.write_result`` now does not print blanks if a higher-order index differs from the previous row. Also added testcase for this.
1291ead
to
6eadb87
Compare
@@ -415,6 +415,7 @@ I/O | |||
- Bug in :func:`read_stata` where value labels could not be read when using an iterator (:issue:`16923`) | |||
- Bug in :func:`read_html` where import check fails when run in multiple threads (:issue:`16928`) | |||
- Bug in :func:`read_csv` where automatic delimiter detection caused a ``TypeError`` to be thrown when a bad line was encountered rather than the correct error message (:issue:`13374`) | |||
- Bug in :func:`to_latex` where repeated multi-index values were not printed even though a higher level index differed from the previous row (:issue:`14484`) |
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.
can you move to 0.21.1
@@ -221,6 +221,28 @@ def test_to_latex_multiindex(self): | |||
|
|||
assert result == expected | |||
|
|||
# GH 14484 |
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.
can you make this a separate test
can you update |
@jreback : I can carry this one to the finish line. |
great! feel free to pick up any PR that is not responsive from the author and can be finished |
* BUG: LatexFormatter.write_result multi-index Fixed GH issue 14484: `LatexFormatter.write_result`` now does not print blanks if a higher-order index differs from the previous row. Also added testcase for this. * MAINT: Address reviewer comments Closes pandas-devgh-14484 Closes pandas-devgh-17499
Fixed GH issue 14484:
LatexFormatter.write_result(...)
now does not print blanks if ahigher-order index differs from the previous row.
Also added testcase for this.
git diff upstream/master -u -- "*.py" | flake8 --diff