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.1.tar.gz (4.1 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.1-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ethnicities-0.0.1.tar.gz
  • Upload date:
  • Size: 4.1 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.1.tar.gz
Algorithm Hash digest
SHA256 1df60bfdec0b13a27ede47dcb11fe5e16a0d56b723357b6f890b27e589f932ef
MD5 0a1dbcbc082f97449288db76304110db
BLAKE2b-256 4c2393b8548ca7f9a86f8e566da8f131db0db5684481ff2bfb94b5e6157508af

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ethnicities-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 5.4 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f6726dea04c81a90d6a6d262858524d418ce0c403cdab0b745e9e5f8e05281e7
MD5 19875cb65bdd4851407d90d8ecc9ed8c
BLAKE2b-256 b15e36dbfeebb4a71ed746887c4eedd5c0110d22dd8152aabafce214c8571de1

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