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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

jim-smith opened this issue · comments

eg from stata:
acro table year survivor

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(' ','_')