-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Fix to_latex with longtable (#17959) #17960
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 with longtable (#17959) #17960
Conversation
Codecov Report
@@ Coverage Diff @@
## master #17960 +/- ##
==========================================
- Coverage 91.6% 91.58% -0.02%
==========================================
Files 153 153
Lines 51306 51306
==========================================
- Hits 46998 46990 -8
- Misses 4308 4316 +8
Continue to review full report at Codecov.
|
@syxolk : You just need a |
b3eccbc
to
7a71573
Compare
I just added the whatsnew entry and squashed the commits. |
@@ -365,7 +365,7 @@ def test_to_latex_longtable(self, frame): | |||
\midrule | |||
\endhead | |||
\midrule | |||
\multicolumn{3}{r}{{Continued on next page}} \\ |
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 sure we are testing for 0, 1, 2, 3 columns (you don't have to fully compare the output, just assert that the multicolumn directive is correct)
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.
Just added test cases for 1 and 3 columns. We already had a test case with 2 columns. I don't think tables with 0 columns make any sense. What do you 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.
sure they do, an empty dataframe is possible
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 : The code has a deliberate short-circuit for an empty DataFrame
, and this pattern will not be followed for 0 columns in fact. I added a couple of tests for that short-circuit.
doc/source/whatsnew/v0.21.0.txt
Outdated
@@ -998,6 +998,7 @@ I/O | |||
- Bug in :meth:`DataFrame.to_html` in which there was no validation of the ``justify`` parameter (:issue:`17527`) | |||
- Bug in :func:`HDFStore.select` when reading a contiguous mixed-data table featuring VLArray (:issue:`17021`) | |||
- Bug in :func:`to_json` where several conditions (including objects with unprintable symbols, objects with deep recursion, overlong labels) caused segfaults instead of raising the appropriate exception (:issue:`14256`) | |||
- Bug in :meth:`DataFrame.to_latex` with ``longtable=True`` where a latex multicolumn always spanned over three columns (:issue:`17959`) | |||
|
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.
move to 0.21.1
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.
can you rebase & update |
can you update? |
@jreback : I can carry this to the finish line. |
23fc5d3
to
324b780
Compare
Thanks! Sorry, I was quite busy. |
pandas.DataFrame.to_latex(longtable=True) always contained \multicolumn{3}{r}{{Continued on next page}} regardless of the number of columns in the output.
677a27d
to
9b4d30e
Compare
* Move whatsnew to 0.21.1.txt * Empty tests for empty DataFrame in to_latex
9b4d30e
to
930471d
Compare
@jreback : All changes have been addressed. PTAL. |
closes pandas-dev#17959 (cherry picked from commit e909ea0)
A vestige of gh-17960. Should have been removed before merge.
Version 0.22.0 * tag 'v0.22.0': (777 commits) RLS: v0.22.0 DOC: Fix min_count docstring (pandas-dev#19005) DOC: More 0.22.0 updates (pandas-dev#19002) TST: Remove pow test in expressions COMPAT: Avoid td.skip decorator DOC: 0.22.0 release docs (pandas-dev#18983) DOC: Include 0.22.0 whatsnew Breaking changes for sum / prod of empty / all-NA (pandas-dev#18921) ENH: Added a min_count keyword to stat funcs (pandas-dev#18876) RLS: v0.21.1 DOC: Add date to whatsnew (pandas-dev#18740) DOC: Include 0.21.1 whatsnew DOC: Update relase notes (pandas-dev#18739) CFG: Ignore W503 DOC: fix options table (pandas-dev#18730) ENH: support non default indexes in writing to Parquet (pandas-dev#18629) BUG: Fix to_latex with longtable (pandas-dev#17959) (pandas-dev#17960) Parquet: Add error message for no engine found (pandas-dev#18717) BUG: Categorical data fails to load from hdf when all columns are NaN (pandas-dev#18652) DOC: clean-up whatsnew file for 0.21.1 (pandas-dev#18690) ...
* releases: (777 commits) RLS: v0.22.0 DOC: Fix min_count docstring (pandas-dev#19005) DOC: More 0.22.0 updates (pandas-dev#19002) TST: Remove pow test in expressions COMPAT: Avoid td.skip decorator DOC: 0.22.0 release docs (pandas-dev#18983) DOC: Include 0.22.0 whatsnew Breaking changes for sum / prod of empty / all-NA (pandas-dev#18921) ENH: Added a min_count keyword to stat funcs (pandas-dev#18876) RLS: v0.21.1 DOC: Add date to whatsnew (pandas-dev#18740) DOC: Include 0.21.1 whatsnew DOC: Update relase notes (pandas-dev#18739) CFG: Ignore W503 DOC: fix options table (pandas-dev#18730) ENH: support non default indexes in writing to Parquet (pandas-dev#18629) BUG: Fix to_latex with longtable (pandas-dev#17959) (pandas-dev#17960) Parquet: Add error message for no engine found (pandas-dev#18717) BUG: Categorical data fails to load from hdf when all columns are NaN (pandas-dev#18652) DOC: clean-up whatsnew file for 0.21.1 (pandas-dev#18690) ...
git diff upstream/master -u -- "*.py" | flake8 --diff
pandas.DataFrame.to_latex(longtable=True) always contained
\multicolumn{3}{r}{{Continued on next page}}
regardless of the number of columns in the output. This is now changed to use the actual number of columns in the output.