Skip to content

📊 Add long-run US immigration data (DHS) - #6498

Open
edomt wants to merge 51 commits into
masterfrom
data-add-longrun-us
Open

📊 Add long-run US immigration data (DHS)#6498
edomt wants to merge 51 commits into
masterfrom
data-add-longrun-us

Conversation

@edomt

@edomt edomt commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Written by Claude Fable 5 — @edomt at the wheel.

Part of https://github.com/owid/owid-issues/issues/2467 (long-term migration data for the United States).

Adds two new datasets:

1. Legal permanent residents (flow) — us_lawful_permanent_residents

The number of people obtaining legal permanent resident status, from the DHS Yearbook of Immigration Statistics:

  • Annual totals, 1820–2024 (2024 yearbook), plus a rate per 1,000 US population.
  • By country of origin, by decade, 1820s–2010s (2020 yearbook, the last edition with this breakdown).
  • By region of origin, by decade — rebuilt from the country rows using OWID region definitions.

Notes:

  • Country names kept as published (Russia, Czechoslovakia, Yugoslavia, Korea…), except "Canada and Newfoundland" → Canada. Combined rows (Austria-Hungary, Norway-Sweden) are used until the separate countries fully reconcile with them; the separate countries are used from then on.
  • Canada and Mexico are dropped from the country table before the 1910s (overland arrivals were not fully counted until 1908) but still count toward regional totals.
  • Sanity checks assert the rebuilt regional totals match the source's aggregates exactly, and that the two yearbook editions agree on decade totals within 1%.

2. Foreign-born population (stock) — us_foreign_born_population

The foreign-born population and its share of the total population, 1850–2024:

  • 1850–2000 (decennial): Census Bureau working paper "Historical Census Statistics on the Foreign-Born Population of the United States" (Gibson & Jung 2006), parsed from Table 1 of the PDF.
  • 2005–2024 (annual): American Community Survey 1-year estimates (table B05002), via the Census Bureau API. No 2020 value (not released due to the pandemic).

Also broken down by country of birth (133 entities) and by region of birth (OWID regions):

  • 1850–2000 (decennial): Table 4 of the same working paper, now snapshotted as the XLS files the Census Bureau publishes alongside the PDF (the earlier PDF snapshot is replaced). No 1940/1950 (only published for the White population back then).
  • 2005–2024 (annual): ACS table B05006 via the API, storing each year's raw variable codes and labels (they shift between years).
  • Countries are kept as the sources report them (Czechoslovakia stays combined even today, Korea covers both Koreas, China excludes Hong Kong and Taiwan since 1980). The United Kingdom series uses the source's Great Britain row before 1930, and Turkey combines the source's "Turkey in Europe" and "Turkey in Asia" rows.
  • Region aggregates are rebuilt on OWID definitions from the sources' own aggregate rows, with an exact-partition assert against the total in every year.

Sanity checks pin parsed values and computed shares to figures printed in the working paper (e.g. 1890 = 14.8%, 1970 = 4.7%).

🤖 Generated with Claude Code

@owidbot

owidbot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Quick links (staging server):

Site Dev Site Preview Admin Wizard Docs Docs Preview

Login: ssh owid@staging-site-data-add-longrun-us

chart-diff: ❌
  • 0/9 reviewed charts
  • Modified: 0/0
  • New: 0/9
  • Rejected: 0
  • Data changes: 0
  • Metadata changes: 0
data-diff: ❌ 1 changed · 2 new · 6 identical — full report
~ garden/regions/2023-01-01/regions
    ~ regions.code dim (removed data)
        - Removed values: 14 / 436 (3.21%)
            EI_AFR
            EI_APAC
            EI_CIS
            (+11 more)
    ~ regions.defined_by (changed data)
        - Removed values: 14 / 436 (3.21%)
            EI_AFR: ei
            EI_APAC: ei
            EI_CIS: ei
            (+11 more)
    ~ regions.is_historical (changed data)
        - Removed values: 14 / 436 (3.21%)
            EI_AFR: False
            EI_APAC: False
            EI_CIS: False
            (+11 more)
    ~ regions.members (changed data)
        - Removed values: 14 / 436 (3.21%)
            EI_AFR: ["AGO", "BDI", "BEN", "BFA", "BWA", "CAF", "CIV", "CMR", "COD", "COG", "COM", "CPV", "DJI", "DZA", "EGY", "ERI", "ESH", "ETH", "GAB", "GHA", "GIN", "GM…
            EI_APAC: ["AFG", "ASM", "AUS", "BGD", "BRN", "BTN", "CCK", "CHN", "COK", "CXR", "FJI", "FSM", "GUM", "HKG", "IDN", "IND", "JPN", "KHM", "KIR", "KOR", "LAO", "L…
            EI_CIS: ["ARM", "AZE", "BLR", "KAZ", "KGZ", "MDA", "RUS", "TJK", "TKM", "UZB"]
            (+11 more)
    ~ regions.name (changed data)
        - Removed values: 14 / 436 (3.21%)
            EI_AFR: Africa (EI)
            EI_APAC: Asia Pacific (EI)
            EI_CIS: CIS (EI)
            (+11 more)
    ~ regions.region_type (changed data)
        - Removed values: 14 / 436 (3.21%)
            EI_AFR: aggregate
            EI_APAC: aggregate
            EI_CIS: aggregate
            (+11 more)
    ~ regions.short_name (changed data)
        - Removed values: 14 / 436 (3.21%)
            EI_AFR: Africa (EI)
            EI_APAC: Asia Pacific (EI)
            EI_CIS: CIS (EI)
            (+11 more)
+ garden/migration/2026-07-22/us_foreign_born_population (new dataset: 4 table(s), 5 column(s))
+ garden/migration/2026-07-22/us_lawful_permanent_residents (new dataset: 3 table(s), 4 column(s))

= 6 compared dataset(s) turned out identical; details in the full report

Automatically updated datasets matching excess_mortality|covid|fluid|flunet|country_profile|garden/ihme_gbd/2019/gbd_risk are not included. Run locally with etl diff REMOTE data/ --include <dataset> --verbose.

Edited: 2026-08-10 12:10:43 UTC
Execution time: 43.58 seconds

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@edomt

edomt commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ad8cd542b4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread etl/steps/data/garden/migration/2026-07-22/us_lawful_permanent_residents.py Outdated
edomt and others added 2 commits July 22, 2026 12:36
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…e rows are partial

The separate Austria and Hungary rows do not cover all years in the
1860s, 1890s, and 1900s (Table 2, footnote 2), so preferring them over
the combined row dropped the unallocated remainder (~846k people in
total) from the by-country table. Switch from the combined row to the
separate rows only from the first decade after which the separate rows
always add up to the combined row.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@edomt

edomt commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

edomt and others added 3 commits July 22, 2026 12:40
…nces

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: 2d0f3f1981

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

edomt and others added 11 commits July 22, 2026 12:54
…ion bullets

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…description bullets

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…, style fixes

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@edomt edomt self-assigned this Jul 22, 2026
Move the status-grants note below the counting-changes text and keep the description key order aligned with that presentation.
@edomt
edomt marked this pull request as ready for review July 22, 2026 12:12
edomt and others added 4 commits July 22, 2026 14:39
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…aveats

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@edomt

edomt commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

edomt and others added 4 commits July 22, 2026 15:33
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: 253e55bbaa

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

edomt and others added 9 commits July 22, 2026 15:44
…+ ACS)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…mplate

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
In both by-country tables, people not attributed to a listed country now
appear as e.g. "Asia (not specified)" when the source gives their region,
with plain "Not specified" kept for the truly unrecorded. The stock
dataset's by-country selection is rewritten as an exact-cover walk of the
source's hierarchy, so remainders of rows whose sub-rows do not add up
(Yugoslavia, Portugal) are captured and every year is asserted to add up
to the source's total. Also adds entity annotations for Korea,
Czechoslovakia, and Yugoslavia, and corrects the China/Hong Kong bullet.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@edomt

edomt commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: 0b62b3bbef

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

edomt and others added 8 commits July 23, 2026 09:53
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
New share_by_origin_group table (Africa, Asia, Oceania, Europe, Mexico,
Canada, Rest of America, Not specified), as requested for the stacked
long-run chart. Also removes the dead pre-walker selection functions.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@edomt

edomt commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: 3ad239cb10

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants