Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Lower all values
- df.columns = [x.lower() for x in df.columns]
- # Strip out punctuation, replace spaces and lower
- df.columns = df.columns.str.replace("[^\w\s]", "").str.replace(" ", "_").str.lower()
- # Condense multiindex columns
- df.columns = ["_".join(col).lower() for col in df.columns]
- # Double transpose to remove bottom row for multiindex columns
- df.T.reset_index(1, drop=True).T
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement