Open bileamScheuvens opened 9 months ago
duplicated: #47489
closest fix: #48936
This can be fixed with
df1.to_latex(escape=True)
The document says
By default, the value will be read from the pandas config module and set to True if the option styler.format.escape is “latex”. When set to False prevents from escaping latex special characters in column names. Changed in version 2.0.0: The pandas option affecting this argument has changed, as has the default value to False.
Don't know why this relies on styler.format.escape
. But default to True would be more sensible imo.
This can be fixed with
df1.to_latex(escape=True)
Did you test this? The example includes
escape=True
Pandas version checks
[ ] I have checked that this issue has not already been reported.
[X] I have confirmed this bug exists on the latest version of pandas.
[X] I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
Issue Description
The resulting table includes the raw index name, instead of escaping properly.
Expected Behavior
Installed Versions
INSTALLED VERSIONS
commit : f538741432edf55c6b9fb5d0d496d2dd1d7c2457 python : 3.10.8.final.0 python-bits : 64 OS : Windows OS-release : 10 Version : 10.0.22631 machine : AMD64 processor : Intel64 Family 6 Model 183 Stepping 1, GenuineIntel byteorder : little LC_ALL : None LANG : None LOCALE : de_DE.cp1252
pandas : 2.2.0 numpy : 1.26.2 pytz : 2023.3.post1 dateutil : 2.8.2 setuptools : 69.0.3 pip : 23.1.2 Cython : None pytest : 8.0.0 hypothesis : None sphinx : None blosc : None feather : None xlsxwriter : None lxml.etree : 5.0.1 html5lib : None pymysql : None psycopg2 : None jinja2 : 3.1.2 IPython : 8.20.0 pandas_datareader : None adbc-driver-postgresql: None adbc-driver-sqlite : None bs4 : 4.12.2 bottleneck : None dataframe-api-compat : None fastparquet : None fsspec : 2023.12.2 gcsfs : None matplotlib : None numba : None numexpr : None odfpy : None openpyxl : None pandas_gbq : None pyarrow : None pyreadstat : None python-calamine : None pyxlsb : None s3fs : None scipy : 1.11.4 sqlalchemy : None tables : None tabulate : None xarray : None xlrd : None zstandard : None tzdata : 2023.4 qtpy : None pyqt5 : None