Skip to main content

commondata-countries

PyPI - License PyPI - Python Version

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"]
# Equivalent to
country = countries.get("Untied States of America")

# Lookup by ISO Alpha-2
country = countries["US"]
# Equivalent to
country = countries.get("US")

# Lookup by ISO Alpha-3
country = countries["USA"]
# Equivalent to
country = countries.get("USA")

# Lookup by ISO Numeric
country = countries[840]
# Equivalent to
country = countries.get(840)

# Lookup by synonym
country = countries["United States"]

# Search matching countries (ordered by best match first)
countries = countries.search("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.

Release files for commondata-countries 2.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for commondata-countries 2.3.0
File Size Uploaded
commondata_countries-2.3.0.tar.gz 24.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for commondata-countries 2.3.0
File Interpreter ABI Platform
commondata_countries-2.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 48.9 kB

Release files / commondata_countries-2.3.0.tar.gz

Download URL commondata_countries-2.3.0.tar.gz
Size 24.3 kB
Tags Source
SHA-256 checksum
How to use checksums
dd4808269976c3382a309a26ec73e1d7e75abf69810180a1e6965d80bacf8835
BLAKE2b-256 checksum
How to use checksums
60d3faef8c8bdf0d553aa6d229909a4699f9300345f6e1038b20ba3e7a0393a0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 2, 2025.

Transparency log

Release files / commondata_countries-2.3.0-py3-none-any.whl

Download URL commondata_countries-2.3.0-py3-none-any.whl
Size 24.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6e6476b5449a651827ea29c3fb508e33e6a167ad23b3a2ce631db31b2ce9fe03
BLAKE2b-256 checksum
How to use checksums
0930ee8d4582c3a5c762911cb2db444693bde9b09ceaab4a40c49c1f4117ed71
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 2, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

2.3.0 This release

2 release files

2.2.3

2 release files

2.2.2

2 release files

2.2.1

2 release files

2.2.0

2 release files

2.1.5

2 release files

2.1.4

2 release files

2.1.3

2 release files

2.1.1

2 release files

2.1.0

2 release files

1.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page