Pandas to latex, cannot drop index

Viewed 57

I'm trying to drop my row numbering when I export a pandas (ver 1.4.3) dataframe to latex code. I've found that I should include the command 'index=False'. However when I run my code I get an error that the styler does not include 'index'.

error code:

  File "/home/-/GitHub/-/latex/step1_feet_bottom.py", line 43, in get_feet
    excel = excel.to_latex(index=False,

TypeError: Styler.to_latex() got an unexpected keyword argument 'index'

This is my code:

latex = df.copy()
latex = latex.round(1)
latex = latex.style.format(na_rep='-', precision=1)
latex = latex.to_latex(index=False,
    column_format="rrrrr", position="h", position_float="centering",
    hrules=True, label="table:5", caption="Styled LaTeX Table",
    multirow_align="t", multicol_align="r"
    )  
print(latex)

One weird thing is the following, if I include na_rep='-' in to_latex I get the same error. My first guess was that I was running an old version of pandas, I am however running the latest version 1.4.3

Thank you in advance.

0 Answers
Related