Skip to content

Commit

Permalink
latex table in scirpt
Browse files Browse the repository at this point in the history
  • Loading branch information
smilesun committed Dec 5, 2024
1 parent 747476c commit 51c26d1
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions scripts/generate_latex_table.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"""
aggregate benchmark csv file to generate latex table
"""
import argparse
import pandas as pd


def gen_latex_table(raw_df, fname="table_perf.tex",
group="method", str_perf="acc"):
"""
aggregate benchmark csv file to generate latex table
"""
df_result = raw_df.groupby(group)[str_perf].agg(["mean", "std"])
latex_table = df_result.to_latex(float_format="%.3f")
with open(fname, 'w') as file:
file.write(latex_table)


if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Read a CSV file")
parser.add_argument("filename", help="Name of the CSV file to read")
args = parser.parse_args()

df = pd.read_csv(args.filename, index_col=False, skipinitialspace=True)
gen_latex_table(df)

0 comments on commit 51c26d1

Please sign in to comment.