-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: DataFrame.style.to_latex() does not allow index=False
as a parameter and does not return consistent
#55188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I do get the >>> print(df.style.to_latex(index=False))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: Styler.to_latex() got an unexpected keyword argument 'index' The Future warning doesn't occur for >>> print(df.to_latex(index=False))
\begin{tabular}{rrrr}
\toprule
A & B & C & D \\
\midrule
-1.141720 & -0.864452 & 0.281404 & -0.191118 \\
0.339318 & 0.526344 & -0.273565 & -1.143412 \\
-0.097656 & -0.653314 & -1.001223 & 0.227216 \\
0.916563 & -0.667892 & 0.759713 & 0.856244 \\
-2.211459 & -0.143264 & -0.364037 & -0.379071 \\
-0.658746 & 0.961309 & 1.973678 & -0.464108 \\
-0.874616 & 0.039770 & -0.398601 & -0.333741 \\
-0.568972 & 0.631231 & -1.278331 & 0.050330 \\
0.803613 & 0.155475 & -0.370566 & -1.728852 \\
-0.597297 & -1.037614 & -1.215433 & 1.180112 \\
\bottomrule
\end{tabular} |
cc @attack68 |
This will not be allowed: df.style.to_latex(index=False) The solution is: df.style.hide().to_latex() The reason is to minimise the arguments supplied to
I understand that |
Then should the futurewarning be removed, since there's no plan to remove |
You have ticked "I have confirmed this exists on the latest version of pandas". You have specified you are using 1.5.3. The latest version is 2.1.x. @paulreece states:
Feel free to close if this addresses your query. |
Pandas version checks
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
Issue Description
The second will not work, but it would be great to keep the option for
index=False
in order to ensure backward compatibility (unless the futurewarning applies to pandas 3.0+)I expect this will break backward compatibility if pandas is upgraded to <3 but >2.1 (according to futurewarning)
Expected Behavior
df.style.to_latex(index=False)
should work just likedf.style.hide_index().to_latex()
Installed Versions
INSTALLED VERSIONS
commit : 2e218d1
python : 3.8.16.final.0
python-bits : 64
OS : Linux
OS-release : 5.15.0-56-generic
Version : #62-Ubuntu SMP Tue Nov 22 19:54:14 UTC 2022
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.5.3
numpy : 1.24.4
pytz : 2023.3
dateutil : 2.8.2
setuptools : 56.0.0
pip : 22.0.4
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.9.2
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.1.2
IPython : 8.12.2
pandas_datareader: None
bs4 : 4.11.2
bottleneck : None
brotli : None
fastparquet : None
fsspec : 2023.6.0
gcsfs : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 13.0.0
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : 1.10.1
snappy : None
sqlalchemy : None
tables : None
tabulate : 0.9.0
xarray : None
xlrd : None
xlwt : None
zstandard : None
tzdata : None
The text was updated successfully, but these errors were encountered: