hh-data-ml: census microdata subset
A subset of population and housing census microdata from an unnamed country (not identified for privacy reasons); one row per person. Back to Course datasets
WarningFor course use only
This is real census microdata, not synthetic data. Use it only for the course exercises: don’t share it, copy it elsewhere or try to identify any person or household.
File
| File | data/raw/hh-data-ml.csv |
| Size on disk | 3.1 GB |
| Format | CSV with a header row; pipe-delimited (|) |
| Rows | about 26 million (estimated from file size) |
| Used in | Day 5 (machine learning) |
Columns
| # | Name | Type | Description |
|---|---|---|---|
| 0 | (no name) | integer | Row number left over from an earlier export; not a variable |
| 1 | prov_id |
integer | Province code |
| 2 | reg_id |
integer | Region code |
| 3 | dist_id |
integer | District code |
| 4 | adm4 |
integer | Administrative level 4 code (the level below district) |
| 5 | urban_rural |
integer | Whether the person lives in an urban or rural area |
| 6 | hh_id |
integer | Household ID. It also contains the geographic codes above |
| 7 | P03 |
integer | Relationship to the head of household (0 head, 1 spouse, 2 son/daughter, 3 father/mother, 4 father-/mother-in-law, 5 son-/daughter-in-law, 6 grandchild, 7 other relative of the head, 8 other relative of the spouse, 9 not related) |
| 8 | P05 |
integer | Sex (1 male, 2 female) |
| 9 | P07M |
integer | Month of birth |
| 10 | P07A |
integer | Year of birth |
| 11 | P08 |
integer | Age in years |
| 12 | lan_spoken_local |
integer | Speaks a local language fluently (1 yes, 2 no) |
| 13 | lan_spoken_fr |
integer | Speaks French fluently (1 yes, 2 no) |
| 14 | lan_spoken_en |
integer | Speaks English fluently (1 yes, 2 no) |
| 15 | lan_spoken_other |
integer | Speaks another language fluently (1 yes, 2 no) |
| 16 | lan_read_write_local |
integer | Reads and writes a local language (1 yes, 2 no) |
| 17 | lan_read_write_fr |
integer | Reads and writes French (1 yes, 2 no) |
| 18 | lan_read_write_en |
integer | Reads and writes English (1 yes, 2 no) |
| 19 | lan_read_write_other |
integer | Reads and writes another language (1 yes, 2 no) |
| 20 | P21 |
integer | School attendance (0 never attended, 1 attended in the past, 2 attending now) |
| 21 | P22N |
integer | Highest school level attended; asked of everyone aged 3 and over |
| 22 | P23 |
integer | Activity status (1 employed, 2 unemployed, 3 looking for a first job, 4 homemaker, 5 pupil/student, 6 retired, 7 unable to work, 8 other) |
| 23 | P25 |
integer | Employment status (1 self-employed, 2 employer, 3 public-sector employee, 4 private-sector employee, 5 piece worker, 6 apprentice or family worker, 8 other) |
| 24 | P28 |
integer | Marital status (1 single, 2 married, 3 divorced/separated, 4 widowed) |
| 25 | P29 |
integer | Age at marriage |
| 26 | change_log |
text | Metadata: when the file was last changed; not a variable |
Column descriptions come from the notebook Description of the Household Dataset.
Notes
- The file is pipe-delimited. Use
sep="|"in pandas or.option("sep", "|")in Spark. - The first column has no name: drop it, or pandas reads it as
Unnamed: 0. - Missing values are expected where a question doesn’t apply: for example,
P25(employment status) only for people who work,P29(age at marriage) only for people who have married, and the language and education columns for young children. UseP22Nto tell “missing” from “not applicable” for education (everyone aged 3+ should have a value). - Codes are numbers: recode them to labels before plotting or modelling.
hh_ididentifies the household, so you can compute household size by grouping on it.