Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

convert pandas data frame to latex file

import pandas as pd
df = pd.DataFrame({"a":range(10), "b":range(10,20)})
with open("my_table.tex", "w") as f:
    f.write("egin{tabular}{" + " | ".join(["c"] * len(df.columns)) + "}
")
    for i, row in df.iterrows():
        f.write(" & ".join([str(x) for x in row.values]) + " \
")
    f.write("end{tabular}")
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #convert #pandas #data #frame #latex #file
ADD COMMENT
Topic
Name
2+8 =