Skip to content

Instantly share code, notes, and snippets.

@lgallen
Created March 29, 2020 19:59
Show Gist options
  • Save lgallen/f9b6ce17f340479f9d774af2d8fffbf8 to your computer and use it in GitHub Desktop.
Save lgallen/f9b6ce17f340479f9d774af2d8fffbf8 to your computer and use it in GitHub Desktop.
Find unique pairs
# Generated as example for Springboard mentees
import pandas as pd
df = pd.DataFrame()
df['code'] = ['1', '1', '2', '3', '3', '3', '3', '4', '4']
df['country'] = ['usa', '', 'france', 'japan', 'japan', '', 'japan', 'brazil', 'brazil']
df['extracolumn'] = ['i', 'do', 'not', 'need', 'the', 'stuff', 'in', 'this', 'column']
new_df = df[['code', 'country']].drop_duplicates()
new_df = new_df[new_df['country'] != '']
new_df
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment