Pandas column access w/column names containing spaces

Old post, but may be interesting: an idea (which is destructive, but does the job if you want it quick and dirty) is to rename columns using underscores:

df1.columns = [c.replace(' ', '_') for c in df1.columns]

Leave a Comment