Closed
Description
Code Sample, a copy-pastable example if possible
import numpy as np
import pandas as pd
data = pd.DataFrame(np.random.rand(5,2), columns=['s', 't'])
print(data.rename(columns={'s' : '$s$ in m', 't' : '$t$ in s'}).to_latex(escape=False))
# would be cool to write instead
print(data.to_latex(header=['$s$ in m', '$t$ in s'], escape=False))
# this works as expected
print(data.to_csv(header=['$s$ in m', '$t$ in s'], escape=False))
Problem description
The header option of to_latex
does not rename the columns as in other exporting functions and forces to rename them before.
I am not sure if this is a bug or intended.
But it is counterintuitive (at least for me) and makes code harder to read.
Expected Output
# would be cool to write instead
print(data.to_latex(header=['$s$ in m', '$t$ in s'], escape=False))
Output of pd.show_versions()
INSTALLED VERSIONS
------------------
commit: None
python: 3.5.2.final.0
python-bits: 64
OS: Linux
OS-release: 4.4.0-64-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
pandas: 0.18.1
nose: 1.3.7
pip: 9.0.1
setuptools: 23.0.0
Cython: 0.24
numpy: 1.11.2
scipy: 0.17.1
statsmodels: None
xarray: None
IPython: 4.2.0
sphinx: 1.4.6
patsy: 0.4.1
dateutil: 2.5.3
pytz: 2016.4
blosc: None
bottleneck: 1.1.0
tables: 3.2.2
numexpr: 2.6.0
matplotlib: 1.5.1
openpyxl: 2.3.2
xlrd: 1.0.0
xlwt: 1.1.2
xlsxwriter: 0.9.2
lxml: 3.6.0
bs4: 4.4.1
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: 1.0.13
pymysql: None
psycopg2: None
jinja2: 2.8
boto: 2.40.0
pandas_datareader: None