I am new to Latex
I need to add the data of above into table (in latex). I have a pandas
DataFrame
which evaluates this result. and I know the use of .to_latex()
. But after that I don't know how to add this data into table?
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.
Sign up to join this communityThe to_latex()
makes a finished tabular
, so you just need to write that to a file, and use \input
in your LaTeX document.
Assuming Python 3, here is a minimal Python example to make a DataFrame and save as a text file:
import pandas as pd
df = pd.DataFrame(['Foo','Bar','Baz'])
with open('mytable.tex','w') as tf:
tf.write(df.to_latex())
A minimal LaTeX example using the exported table code, will then be
\documentclass{article}
\usepackage{booktabs}
\begin{document}
\input{mytable}
\end{document}
The booktabs
package is required as to_latex()
uses its commands for table rules. This assumes that mytable.tex
is in the same folder.
\input
that file in your document?)
Oct 1, 2017 at 19:09