Time series data on African-born immigrant populations in the U.S. (by state) and Canada (by province and Territory), built from Census Bureau ACS estimates and Statistics Canada census tables.
# African Immigrant Population by State/Province
Time series data on African-born immigrant populations in the United States (by state) and Canada (by province/territory).
## Data
### Canada
Total African-born population by province/territory from the Canadian census (2001, 2006, 2011, 2016, 2021).
| Output | Description |
|---|---|
| `canada_african_immigrant_population_wide.csv` | Province x census year matrix |
| `canada_african_immigrant_population_long.csv` | One row per province-year |
**Source**: Statistics Canada census topic-based tabulations (2001-2016) and table 98-10-0307-01 via WDS API (2021).
### United States
Total African-born population by state from the American Community Survey.
**ACS 1-Year** (annual, 2005-2024 excluding 2020):
| Output | Description |
|---|---|
| `us_african_immigrant_population_wide.csv` | State x year matrix |
| `us_african_immigrant_population_long.csv` | One row per state-year |
Note: ~22 states return null each year due to small sample sizes in the 1-year estimates.
**ACS 5-Year** (non-overlapping periods with full state coverage):
| Output | Description |
|---|---|
| `us_african_immigrant_population_5yr_wide.csv` | State x period matrix |
| `us_african_immigrant_population_5yr_long.csv` | One row per state-period |
Periods: 2005-2009, 2010-2014, 2015-2019, 2019-2023. The last two periods share 2019.
## Scripts
| Script | Description |
|---|---|
| `canada_african_immigrant_population.py` | Fetch Canada census data (HTML scraping + API) |
| `us_african_immigrant_population.py` | Fetch U.S. ACS 1-year data |
| `us_african_immigrant_population_5yr.py` | Fetch U.S. ACS 5-year data |
| `fact_check.py` | Validate Canada output against national totals and CSV downloads |
| `fact_check_us.py` | Validate U.S. output against national totals and spot-checks |
## Setup
```bash
uv venv
uv sync
```
The U.S. scripts require a Census API key:
```bash
export CENSUS_API_KEY=your_key_here
```
Get one at
api.census.go …