I'm searching for a list or python packages, to help me unify under one name different names of countries.
For example:
USA, SUA, United States, Unites States of America
Germany, Federal Republic of Germany, Deutschland, Duitsland
I want to consolidate them under the official name, and allocate them iso standard.
This package, country_converter, can do it: https://github.com/konstantinstadler/country_converter
As shown in their documentation,
import country_converter as coco
some_names = ['United Rep. of Tanzania', 'DE', 'Cape Verde', '788', 'Burma', 'COG',
'Iran (Islamic Republic of)', 'Korea, Republic of',
"Dem. People's Rep. of Korea"]
standard_names = coco.convert(names=some_names, to='name_short')
print(standard_names)
Should give
['Tanzania', 'Germany', 'Cabo Verde', 'Tunisia', 'Myanmar', 'Congo Republic', 'Iran', 'South Korea', 'North Korea']
You can also specify the format you want the country names to be printed, by changing the to='name_short'
to to='ISO2'
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