AI-SDC / ACRO

Tools for the Automatic Checking of Research Outputs. These are the tools for researchers to use as drop-in replacements for commands that produce outputs in Stata Python and R
MIT License
15 stars 2 forks source link

prettify_tablestring(data): messes column parsing if first variable value has spaces #200

Closed jim-smith closed 7 months ago

jim-smith commented 7 months ago

eg from stata: acro table year survivor

jim-smith commented 7 months ago

This may be one solution: in-between output = table.to_string(justify="left") and as_strings = output.split("\n")

change the values in outputs to replace spaces with underscores ==> but we just want to focus on the column names.

something like this would strip out spaces from the ends of a common name

remove space in column names using strip() function

df.rename(columns=lambda x: x.strip(), inplace=True) print(df)

so can we adapt it to use x.replace(' ','_')