Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting Nationality to Country in Python [closed]

Tags:

python

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?

like image 260
James C. Avatar asked Jun 27 '17 04:06

James C.


1 Answers

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.

like image 187
J. Meijers Avatar answered Oct 23 '22 03:10

J. Meijers