I have a column in a DataFrame with country code and I want to convert it to the name to plot a graph using the library pycountry
def get_country(n):
country = countries.get(alpha_2 = n)
return country.name
I want to implement the function above using on the DataFrame like this
df['country'] = df['country'].apply(get_country)
and I get this error
AttributeError: 'NoneType' object has no attribute 'name'
get()
returnsNone
by default if the key isn't found. You need to check for this.