I am looking for a library to convert nationality to country name or country code in Python. A data set contains a column with artist name and nationality and I am trying to map them by country.
For example,
Danish = Denmark or DE
Italian = Italy or IT
Japanese = Japan or JP
American = USA or US
I have tried pycountry but it doesn't support nationality. Are there any python libraries to do this?
You could try importing a dictionary for Demonym's
A demonym or gentilic is a word used for people or the inhabitants of a place
One like: Demonym csv listing
And simply do a lookup. If you also want the country code, you need another mapping Country codes mapping
I'm not aware of a complete library for this already existing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With