Repository: pandas-dev/pandas

Issue:
DataFrame.to_latex(): bold_rows option is disregarded
#### Code Sample, a copy-pastable example if possible

```python
import pandas as pd
df = pd.DataFrame({'acol':['a', 'aa'], 'bcol':['b', 'bb']}, index=['row1', 'row2'])
print df.to_latex(bold_rows=True)
```
```
\begin{tabular}{lll}
\toprule
{} & acol & bcol \\
\midrule
row1 &    a &    b \\
row2 &   aa &   bb \\
\bottomrule
\end{tabular}
```
#### Problem description
Despite `bold_rows` is documented to be an option of `to_latex()` and to be `True` by default, in reality, this option has no effect. Moreover, the current behaviour corresponds with what would be expected for `bold_rows=False` and is thus in contrast with the documented default 'bold_rows=True' behaviour.

#### Expected Output
```
\begin{tabular}{lll}
\toprule
{} & acol & bcol \\
\midrule
\textbf{row1} &    a &    b \\
\textbf{row2} &   aa &   bb \\
\bottomrule
\end{tabular}
```
#### Output of ``pd.show_versions()``

INSTALLED VERSIONS
------------------
commit: None
python: 2.7.9.final.0
python-bits: 64
OS: Linux
OS-release: 4.4.0-78-generic
machine: x86_64
processor: 
byteorder: little
LC_ALL: None
LANG: None
LOCALE: None.None

pandas: 0.20.2
pytest: None
pip: 9.0.1
setuptools: 36.0.1
Cython: 0.25.2
numpy: 1.13.0
scipy: 0.19.0
xarray: None
IPython: 5.4.1
sphinx: None
patsy: 0.4.1
dateutil: 2.6.0
pytz: 2017.2
blosc: None
bottleneck: 1.2.1
tables: None
numexpr: 2.6.2
feather: None
matplotlib: 2.0.2
openpyxl: 2.4.8
xlrd: 1.0.0
xlwt: 1.2.0
xlsxwriter: None
lxml: 3.8.0
bs4: 4.6.0
html5lib: 0.999999999
sqlalchemy: 1.1.10
pymysql: 0.7.11.None
psycopg2: None
jinja2: 2.9.6
s3fs: None
pandas_gbq: None
pandas_datareader: None



Discussion:

Resolving patch:
diff --git a/pandas/core/generic.py b/pandas/core/generic.py
--- a/pandas/core/generic.py
+++ b/pandas/core/generic.py
@@ -1538,7 +1538,7 @@ def to_xarray(self):
 
         `to_latex`-specific options:
 
-        bold_rows : boolean, default True
+        bold_rows : boolean, default False
             Make the row labels bold in the output
         column_format : str, default None
             The columns format as specified in `LaTeX table format
@@ -1587,7 +1587,7 @@ def to_xarray(self):
     @Appender(_shared_docs['to_latex'] % _shared_doc_kwargs)
     def to_latex(self, buf=None, columns=None, col_space=None, header=True,
                  index=True, na_rep='NaN', formatters=None, float_format=None,
-                 sparsify=None, index_names=True, bold_rows=True,
+                 sparsify=None, index_names=True, bold_rows=False,
                  column_format=None, longtable=None, escape=None,
                  encoding=None, decimal='.', multicolumn=None,
                  multicolumn_format=None, multirow=None):
diff --git a/pandas/io/formats/format.py b/pandas/io/formats/format.py
--- a/pandas/io/formats/format.py
+++ b/pandas/io/formats/format.py
@@ -845,6 +845,7 @@ def __init__(self, formatter, column_format=None, longtable=False,
                  multicolumn=False, multicolumn_format=None, multirow=False):
         self.fmt = formatter
         self.frame = self.fmt.frame
+        self.bold_rows = self.fmt.kwds.get('bold_rows', False)
         self.column_format = column_format
         self.longtable = longtable
         self.multicolumn = multicolumn
@@ -943,6 +944,11 @@ def get_col_type(dtype):
                          if x else '{}') for x in row]
             else:
                 crow = [x if x else '{}' for x in row]
+            if self.bold_rows and self.fmt.index:
+                # bold row labels
+                crow = ['\\textbf{%s}' % x
+                        if j < ilevels and x.strip() not in ['', '{}'] else x
+                        for j, x in enumerate(crow)]
             if i < clevels and self.fmt.header and self.multicolumn:
                 # sum up columns to multicolumns
                 crow = self._format_multicolumn(crow, ilevels)


Test patch:
diff --git a/pandas/tests/io/formats/test_to_latex.py b/pandas/tests/io/formats/test_to_latex.py
--- a/pandas/tests/io/formats/test_to_latex.py
+++ b/pandas/tests/io/formats/test_to_latex.py
@@ -506,3 +506,33 @@ def test_to_latex_series(self):
 \end{tabular}
 """
         assert withindex_result == withindex_expected
+
+    def test_to_latex_bold_rows(self):
+        # GH 16707
+        df = pd.DataFrame({'a': [1, 2], 'b': ['b1', 'b2']})
+        observed = df.to_latex(bold_rows=True)
+        expected = r"""\begin{tabular}{lrl}
+\toprule
+{} &  a &   b \\
+\midrule
+\textbf{0} &  1 &  b1 \\
+\textbf{1} &  2 &  b2 \\
+\bottomrule
+\end{tabular}
+"""
+        assert observed == expected
+
+    def test_to_latex_no_bold_rows(self):
+        # GH 16707
+        df = pd.DataFrame({'a': [1, 2], 'b': ['b1', 'b2']})
+        observed = df.to_latex(bold_rows=False)
+        expected = r"""\begin{tabular}{lrl}
+\toprule
+{} &  a &   b \\
+\midrule
+0 &  1 &  b1 \\
+1 &  2 &  b2 \\
+\bottomrule
+\end{tabular}
+"""
+        assert observed == expected