Skip to content

Commit 87ab246

Browse files
committed
BUG: fix to_latex bold_rows option (2)
1 parent 3e2dac9 commit 87ab246

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

pandas/io/formats/format.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -945,7 +945,8 @@ def get_col_type(dtype):
945945
crow = [x if x else '{}' for x in row]
946946
if self.fmt.kwds.get('bold_rows', True) and self.fmt.index:
947947
# bold row labels
948-
crow = ['\\textbf{%s}' % x if j < ilevels and x.strip() not in ['', '{}'] else x
948+
crow = ['\\textbf{%s}' % x
949+
if j < ilevels and x.strip() not in ['', '{}'] else x
949950
for j, x in enumerate(crow)]
950951
if i < clevels and self.fmt.header and self.multicolumn:
951952
# sum up columns to multicolumns

pandas/tests/frame/test_repr_info.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,8 @@ def test_latex_repr(self):
178178
\toprule
179179
{} & 0 & 1 & 2 \\
180180
\midrule
181-
0 & $\alpha$ & b & c \\
182-
1 & 1 & 2 & 3 \\
181+
\textbf{0} & $\alpha$ & b & c \\
182+
\textbf{1} & 1 & 2 & 3 \\
183183
\bottomrule
184184
\end{tabular}
185185
"""

pandas/tests/io/formats/test_to_latex.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -509,11 +509,11 @@ def test_to_latex_series(self):
509509

510510
def test_to_latex_bold_rows(self):
511511
# GH 16707
512-
df = DataFrame({'a': [1, 2], 'b': ['b1', 'b2']})
512+
df = pd.DataFrame({'a': [1, 2], 'b': ['b1', 'b2']})
513513
observed = df.to_latex(bold_rows=True)
514514
expected = r"""\begin{tabular}{lrl}
515515
\toprule
516-
\textbf{} & a & b \\
516+
{} & a & b \\
517517
\midrule
518518
\textbf{0} & 1 & b1 \\
519519
\textbf{1} & 2 & b2 \\
@@ -524,7 +524,7 @@ def test_to_latex_bold_rows(self):
524524

525525
def test_to_latex_no_bold_rows(self):
526526
# GH 16707
527-
df = DataFrame({'a': [1, 2], 'b': ['b1', 'b2']})
527+
df = pd.DataFrame({'a': [1, 2], 'b': ['b1', 'b2']})
528528
observed = df.to_latex(bold_rows=False)
529529
expected = r"""\begin{tabular}{lrl}
530530
\toprule

pandas/tests/series/test_repr.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,9 @@ def test_latex_repr(self):
186186
\toprule
187187
{} & 0 \\
188188
\midrule
189-
0 & $\alpha$ \\
190-
1 & b \\
191-
2 & c \\
189+
\textbf{0} & $\alpha$ \\
190+
\textbf{1} & b \\
191+
\textbf{2} & c \\
192192
\bottomrule
193193
\end{tabular}
194194
"""

0 commit comments

Comments
 (0)