Skip to main content

Easily return a list of ethnicities

Project description

Thought for a couple of seconds

# Ethnicities

A lightweight Python package providing lists of the world’s most common ethnicities, organized by region and frequency. All keys are normalized to snake_case (lowercase ASCII, words joined with underscores).

## Installation

```bash
pip install ethnicities

Usage

from ethnicities import all_ethnicities, common, by_region, common_and_by_region

# List all 100 normalized ethnicity names
print(all_ethnicities[:5])
# → ['nigerian', 'ethiopian', 'congolese', 'egyptian', 'south_african']

# Get the “common” subset (e.g. top 20 by global population)
print(common)

# Look up by world region
print(by_region['Europe'])
# → ['russian', 'german', 'french', …, 'icelandic']

# Combined filter: ethnicities that are both “common” and in a given region
print(common_and_by_region['Asia'])

API

  • all_ethnicities List of all 100 normalized ethnicity identifiers.

  • common Subset of all_ethnicities representing the top ~20 by global population.

  • by_region Dictionary mapping region names (e.g. "Africa", "Asia", "Europe", etc.) to lists of normalized identifiers.

  • common_and_by_region Dictionary mapping region names to the intersection of common and by_region[region].

Normalization Rules

  • All identifiers are ASCII lowercase.
  • Spaces, hyphens, and punctuation are replaced with underscores.
  • No diacritics or non-English characters.

Example: “South African” → south_african

Contributing

  1. Fork the repository
  2. Add or update entries in data/… (YAML or JSON).
  3. Run make build to regenerate all_ethnicities.py, by_region.py, etc.
  4. Submit a pull request with tests and documentation updates.

License

Distributed under the MIT License. See LICENSE for details.


**Q1:** Would you like to include a code snippet demonstrating a reverse lookup (display name → normalized key)?  
**Q2:** Should we add a CLI command (e.g. `ethnicities validate`) to enforce normalization rules on new entries?  
**Q3:** Would embedding population metadata or external data-source links into the package enrich your use cases?

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ethnicities-0.0.2.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ethnicities-0.0.2-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file ethnicities-0.0.2.tar.gz.

File metadata

  • Download URL: ethnicities-0.0.2.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.22

File hashes

Hashes for ethnicities-0.0.2.tar.gz
Algorithm Hash digest
SHA256 a0fadde2f01e549150df3d8b5809487e98e5736b22a68fa0e5f032bf0c620565
MD5 98953ad15e68b4a96a78eb411d30b5cd
BLAKE2b-256 79ea5474f5b5dad592d18a66d260e1d09a9ba0dd16d857d948d8b02dc71ddb79

See more details on using hashes here.

File details

Details for the file ethnicities-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: ethnicities-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.22

File hashes

Hashes for ethnicities-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8447abd975075b2a4fa27d571aeabdb21b5cc1ab7f8a61bb6bca899f6f6ffae0
MD5 167422fb264ce2afd831d20bcab4c66d
BLAKE2b-256 8e37bcdc99f9a9e6427fcd82d4add3a9927dbb4c72bbd654423d81cc2f2b33e8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page