Skip to content

Instantly share code, notes, and snippets.

@susanli2016
Created June 21, 2022 03:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save susanli2016/e6ce16e6b1f094812aec96b65e7bde55 to your computer and use it in GitHub Desktop.
Save susanli2016/e6ce16e6b1f094812aec96b65e7bde55 to your computer and use it in GitHub Desktop.
countries = {'US':'United States', 'GB':'United Kingdom', 'FR':'France', 'CA':'Canada', 'DE':'Germany', 'JP':'Japan', 'IT':'Italy'}
def check_country(x):
for country in countries:
if country.lower() in x.lower():
return countries[country]
return ''
df_g7_melt['COUNTRY'] = df_g7_melt['SERIES_ID'].map(lambda x: check_country(x))
df_g7_melt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment