Skip to content

Instantly share code, notes, and snippets.

@fnneves
Last active January 9, 2020 21:12
Show Gist options
  • Save fnneves/e7483dbffe0af272f85cec24cbaa7726 to your computer and use it in GitHub Desktop.
Save fnneves/e7483dbffe0af272f85cec24cbaa7726 to your computer and use it in GitHub Desktop.
def split_columns(df, orig, one, two, separator):
"""
orig: string name of the column we want to split
one: string name of the first new column
two: string name of the second new column
separator: string - this is the character(s) that will define where to split
"""
df[[one,two]] = df[orig].str.split(separator,expand=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment