BUG: DataFrame does not display as LaTeX in Jupyter when it should · Issue #39911 · pandas-dev/pandas (original) (raw)
- [ 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.
But DataFrame
has _repr_latex_
, because this works:
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()
INSTALLED VERSIONS ------------------ commit : 7d32926python : 3.7.9.final.0 python-bits : 64 OS : Linux OS-release : 4.15.0-72-generic Version : #81~16.04.1-Ubuntu SMP Tue Nov 26 16:34:21 UTC 2019 machine : x86_64 processor : x86_64 byteorder : little LC_ALL : None LANG : en_US.UTF-8 LOCALE : en_US.UTF-8
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