Work with ISO 3166-1 alpha2, alpha3 and numeric standard country data
Project description
commondata-countries
Work with ISO 3166-1 alpha2, alpha3 and numeric standard country data.
List, lookup with fuzzy search, and synonyms.
Installation
pip install commondata-countries
Usage
Iterate over all countries:
from commondata_countries import CountryData
countries = CountryData()
for country in countries:
print(country.name)
List all countries:
from commondata_countries import CountryData
countries = CountryData()
print(countries.all())
Lookup a country
from commondata_countries import CountryData
countries = CountryData()
# Lookup by name (case insensitive, fuzzy search)
country = countries["Untied States of America"]
# Lookup by ISO Alpha-2
country = countries["US"]
# Lookup by ISO Alpha-3
country = countries["USA"]
# Lookup by ISO Numeric
country = countries[840]
# Lookup by synonym
country = countries["United States"]
# Look up with fuzzy search
country = countries["United Stat"]
print(country)
> Country(name='United States of America', iso_alpha2='US', iso_alpha3='USA', iso_numeric=840)
Use CLI to lookup a country
python -m commondata-countries United States
Load countries data into pandas dataframe
import pandas as pd
from commondata_countries.data import countries
df = pd.DataFrame(countries)
Other Formats and Datasets
Download CSV, XLSX, JSON and YAML files from commondata.net/countries.
commondata.net maintains a collection of essential datasets in a variety of formats, including python bindings. Check out the full library here: commondata.net/library.
Contributing
Contributions are welcome! Please open an issue or submit a pull request here.
License
This project is licensed under GPLv3. See the LICENSE file for details.
Support
For feedback, feature requests, or support, please email support@commondata.net.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file commondata_countries-2.2.3.tar.gz.
File metadata
- Download URL: commondata_countries-2.2.3.tar.gz
- Upload date:
- Size: 24.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7c261f333126996416cc15f860799df4411eb943506ca921fc8f513ed5d22708
|
|
| MD5 |
82e228aa5cca865ea267c6b25c464eec
|
|
| BLAKE2b-256 |
1da2bd8b729a69e86aef50e21cb2dd497916ff1ccd47ac494891e044b60da2df
|
Provenance
The following attestation bundles were made for commondata_countries-2.2.3.tar.gz:
Publisher:
create-release.yaml on commondata-net/commondata-countries-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
commondata_countries-2.2.3.tar.gz -
Subject digest:
7c261f333126996416cc15f860799df4411eb943506ca921fc8f513ed5d22708 - Sigstore transparency entry: 175905125
- Sigstore integration time:
-
Permalink:
commondata-net/commondata-countries-python@78cc03efc1c6acd04cc856e271ea6440ce393290 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/commondata-net
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
create-release.yaml@78cc03efc1c6acd04cc856e271ea6440ce393290 -
Trigger Event:
workflow_run
-
Statement type:
File details
Details for the file commondata_countries-2.2.3-py3-none-any.whl.
File metadata
- Download URL: commondata_countries-2.2.3-py3-none-any.whl
- Upload date:
- Size: 24.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
65ad95a9fc9c685ec0ce9fc2fe8739e66250b25f77ce597624330fb0d2df258c
|
|
| MD5 |
979d9ea90eb9c7b83300474922018b92
|
|
| BLAKE2b-256 |
12ff2846f7d230cca74780d2c8980bb36aacbd456214be0d9b3718bf26084968
|
Provenance
The following attestation bundles were made for commondata_countries-2.2.3-py3-none-any.whl:
Publisher:
create-release.yaml on commondata-net/commondata-countries-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
commondata_countries-2.2.3-py3-none-any.whl -
Subject digest:
65ad95a9fc9c685ec0ce9fc2fe8739e66250b25f77ce597624330fb0d2df258c - Sigstore transparency entry: 175905126
- Sigstore integration time:
-
Permalink:
commondata-net/commondata-countries-python@78cc03efc1c6acd04cc856e271ea6440ce393290 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/commondata-net
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
create-release.yaml@78cc03efc1c6acd04cc856e271ea6440ce393290 -
Trigger Event:
workflow_run
-
Statement type: