Skip to content

Commit

Permalink
MAINT: Address reviewer comments
Browse files Browse the repository at this point in the history
* Move whatsnew to 0.21.1.txt
* Empty tests for empty DataFrame in to_latex
  • Loading branch information
gfyoung committed Dec 11, 2017
1 parent 60a4fc8 commit 9b4d30e
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 4 deletions.
1 change: 0 additions & 1 deletion doc/source/whatsnew/v0.21.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1089,7 +1089,6 @@ 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`)

Plotting
^^^^^^^^
Expand Down
1 change: 1 addition & 0 deletions doc/source/whatsnew/v0.21.1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ I/O
- Bug in :func:`pandas.io.json.json_normalize` to avoid modification of ``meta`` (:issue:`18610`)
- 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`)
- Bug when reading NaN-only categorical columns in :class:`HDFStore` (:issue:`18413`)
- Bug in :meth:`DataFrame.to_latex` with ``longtable=True`` where a latex multicolumn always spanned over three columns (:issue:`17959`)

Plotting
^^^^^^^^
Expand Down
15 changes: 15 additions & 0 deletions pandas/tests/io/formats/expected.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
\begin{longtable}{lrl}
\toprule
{} & a & b \\
\midrule
\endhead
\midrule
\multicolumn{3}{r}{{Continued on next page}} \\
\midrule
\endfoot

\bottomrule
\endlastfoot
0 & 1 & b1 \\
1 & 2 & b2 \\
\end{longtable}
29 changes: 26 additions & 3 deletions pandas/tests/io/formats/test_to_latex.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,29 @@ def test_to_latex_format(self, frame):

assert withindex_result == withindex_expected

def test_to_latex_empty(self):
df = DataFrame()
result = df.to_latex()
expected = r"""\begin{tabular}{l}
\toprule
Empty DataFrame
Columns: Index([], dtype='object')
Index: Index([], dtype='object') \\
\bottomrule
\end{tabular}
"""
assert result == expected

result = df.to_latex(longtable=True)
expected = r"""\begin{longtable}{l}
\toprule
Empty DataFrame
Columns: Index([], dtype='object')
Index: Index([], dtype='object') \\
\end{longtable}
"""
assert result == expected

def test_to_latex_with_formatters(self):
df = DataFrame({'int': [1, 2, 3],
'float': [1.0, 2.0, 3.0],
Expand Down Expand Up @@ -367,7 +390,7 @@ def test_to_latex_longtable(self, frame):
\midrule
\endhead
\midrule
\multicolumn{2}{r}{{Continued on next page}} \\
\multicolumn{3}{r}{{Continued on next page}} \\
\midrule
\endfoot
Expand All @@ -377,7 +400,7 @@ def test_to_latex_longtable(self, frame):
1 & 2 & b2 \\
\end{longtable}
"""

open("expected.txt", "w").write(withindex_result)
assert withindex_result == withindex_expected

withoutindex_result = df.to_latex(index=False, longtable=True)
Expand All @@ -387,7 +410,7 @@ def test_to_latex_longtable(self, frame):
\midrule
\endhead
\midrule
\multicolumn{3}{r}{{Continued on next page}} \\
\multicolumn{2}{r}{{Continued on next page}} \\
\midrule
\endfoot
Expand Down

0 comments on commit 9b4d30e

Please sign in to comment.