2

I have a dataframe that i read using pd.ExcelFile()

Iam doing like :

xl = pd.ExcelFile('input.xlsx')
df = pd.parse()
latexFormat = df.to_latex()

Now i write latexFormatto a .tex file, by simply opening a file in write mode and then doing fid.write(latexFormat) But it also includes indexes.

How do i remove indexes when writing it to tex file (or) i need to make changes to dataFrame before using to_latex()

mcjoshi
  • 299
  • 1
  • 4
  • 11

2 Answers2

4

Add index=False, e.g.,

latexFormat = df.to_latex(index=False)

Hope this would be helpful.

rojeeer
  • 1,991
  • 1
  • 11
  • 13
  • Actuallly i have numbers in range of $10^{26}$ in one column of dataFrame. I want to write them as strings in .tex format. like 10e+12. How do i do this ? – mcjoshi Sep 29 '17 at 13:55
  • 1
    You may use string format to archive this. For exmaple, `'{.2e}'.format(1e12)` will output `'1.00e+12'` – rojeeer Sep 29 '17 at 14:02
2

You need to use the parameter index=False

latexFormat = df.to_latex(index=False)
Ted Petrou
  • 59,042
  • 19
  • 131
  • 136