Skip to content

Instantly share code, notes, and snippets.

@kstreepy
Created June 1, 2020 15:33
Show Gist options
  • Save kstreepy/17372d5c730fa672e3c2856a4fb7386d to your computer and use it in GitHub Desktop.
Save kstreepy/17372d5c730fa672e3c2856a4fb7386d to your computer and use it in GitHub Desktop.
map in dict as new column
def gs_group(df):
gs_dict = {'GS-1' : 'GS 1-6',
'GS-2' : 'GS 1-6',
'GS-3' : 'GS 1-6',
'GS-4' : 'GS 1-6',
'GS-5' : 'GS 1-6',
'GS-6' : 'GS 1-6',
'GS-7' : 'GS 7-9',
'GS-8' : 'GS 7-9',
'GS-9' : 'GS 7-9',
'GS-10' : 'GS 10-12',
'GS-11' : 'GS 10-12',
'GS-12' : 'GS 10-12',
'GS-13' : 'GS 13',
'GS-14' : 'GS 14',
'GS-15' : 'GS 15',
'Other' : 'Other',
'SES' : 'SES',
'SL' : 'SL & ST',
'ST' : 'SL & ST',
'NULL': None}
df['GS GROUP'] = df['GRADELEVEL'].map(gs_dict)
return df
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment