Description
-
[ X] I have checked that this issue has not already been reported.
-
[ X] I have confirmed this bug exists on the latest version of pandas.
-
(optional) I have confirmed this bug exists on the master branch of pandas.
If you run the following in a Jupyter cell:
import pandas as pd
pd.options.display.latex.repr = True
d = {'one' : [1., 2., 3., 4.],
'two' : [4., 3., 2., 1.]}
df = pd.DataFrame(d)
df
The result is the HTML repr, as usual. But if you select a column, the Series shows the LaTeX repr, as it should.
df['one']
But DataFrame
has _repr_latex_
, because this works:
df._repr_latex_()
So it seems like DataFrame is ignoring the display.latex.repr
option.
Problem description
When display.latex.repr
is True, DataFrames should get represented in LaTeX, not HTML.
Expected Output
'\\begin{tabular}{lrr}\n\\toprule\n{} & one & two \\\\\n\\midrule\n0 & 1.0 & 4.0 \\\\\n1 & 2.0 & 3.0 \\\\\n2 & 3.0 & 2.0 \\\\\n3 & 4.0 & 1.0 \\\\\n\\bottomrule\n\\end{tabular}\n'
Output of pd.show_versions()
pandas : 1.2.2
numpy : 1.19.2
pytz : 2021.1
dateutil : 2.8.1
pip : 21.0.1
setuptools : 52.0.0.post20210125
Cython : None
pytest : 6.2.2
hypothesis : None
sphinx : 3.4.3
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.6.2
html5lib : 1.1
pymysql : None
psycopg2 : None
jinja2 : 2.11.3
IPython : 7.20.0
pandas_datareader: None
bs4 : 4.9.3
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : 3.3.4
numexpr : 2.7.2
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyxlsb : None
s3fs : None
scipy : 1.6.0
sqlalchemy : 1.3.23
tables : 3.6.1
tabulate : None
xarray : None
xlrd : None
xlwt : None
numba : None