Created
June 21, 2022 03:14
-
-
Save susanli2016/e6ce16e6b1f094812aec96b65e7bde55 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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