Skip to content

Instantly share code, notes, and snippets.

@adiamaan92
Created January 28, 2019 22:21
Show Gist options
  • Save adiamaan92/d55d478bb85bfb424d4ea80f2af06d2a to your computer and use it in GitHub Desktop.
Save adiamaan92/d55d478bb85bfb424d4ea80f2af06d2a to your computer and use it in GitHub Desktop.
def setcols(df, fn=lambda x: x.columns.map('_'.join), cols=None):
"""Sets the column of the data frame to the passed column list.
"""
if cols:
df.columns = cols
else:
df.columns = fn(df)
return df
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment