Skip to content

Instantly share code, notes, and snippets.

@ericgitonga
Created May 25, 2021 09:39
Show Gist options
  • Save ericgitonga/b27a02bd8bae469e28e1b20216266f07 to your computer and use it in GitHub Desktop.
Save ericgitonga/b27a02bd8bae469e28e1b20216266f07 to your computer and use it in GitHub Desktop.
Code to get new columns of city and state
df['City'] = df['Location'].apply(lambda x: x.split(', ')[0])
df['State'] = df['Location'].apply(lambda x: x.split(', ')[1])
df[['Company', 'Location', 'City']].head()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment