Project 4 of 12, for Yahya
Census Pivot Tables
Pivot tables of the census for Yahya's wall chart: by parish, by year and by trade, with the Archive's trades index merged in.
Sign up free to open itLog in
Act 5 needs a free account, so your work is saved as you go. Act 1 is open to everyone.
The brief
- YahyaThe census is going on the wall chart, broken down by parish, by year and by trade.
- YahyaThe Archive has a trades index as well, forty years of cards saying things like fisherman is sea and baker is trade.
- PaulSort it into piles and then count each pile, same as you would with screws.
- YahyaI do sort my screws by length, actually. Don't tell Caitlin.
census.csv is the census from the Census Explorer. trades.csv is the trades index: one card per line, with an occupation and its sector.
Write four functions. Each leaves the tables it's given as they were.
parish_table(census): how many people lived in each parish in each census year, as a DataFrame with parishes down the side, years across the top, and 0 where there was nobody.year_summary(census): a DataFrame with one row per census year and four columns:people,households(how many different households),average_age, andper_household(people divided by households).with_sectors(census, trades): the census with asectorcolumn from the index. Everyone stays, once each, in the census's order. An occupation the index hasn't got has the sectorunlisted.sector_table(census, trades): how many people were in each sector in each census year, laid out likeparish_table.
People by parish
year 1921 1951 1981 2011
parish
Bankside 29 35 21 18
Church Street 35 31 18 25
Hill 14 18 9 12
Northgate 12 14 15 13
By census
people households average_age per_household
year
1921 90 23 27.1 3.9
1951 98 26 25.3 3.8
1981 63 26 39.5 2.4
2011 68 26 33.2 2.6
By sector
year 1921 1951 1981 2011
sector
at home 15 15 7 2
children 37 44 11 20
land 5 5 3 9
sea 17 16 16 11
service 4 9 15 9
trade 12 9 11 12
unlisted 0 0 0 5What you learn
What's in it
- Sort into piles, then count each pile
- Five people, three parishes
- Several answers for each pile
- People and trades on the Hill
- A grid of answers
- Nobody in Bankside
- The census, in piles
- Lining two tables up
- The trades index
- One card, two rows
- One card, filed twice
- How Paul would do it
- Fix Riya's version
- Make the wall chart's tables
- Ship it