Project 2 of 12, for Yahya
Census Explorer
A census explorer for Yahya's Archive: ninety years of census returns for the streets round the Clocktower in one pandas table, and the usual questions answered in a line each.
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
- YahyaOne drawer in the Archive is census returns for the streets round here, 1921 to 2011.
- YahyaSomeone typed up one household in three, and anyone they found interesting.
- YahyaI keep asking it the same things, how many on the Hill, who fished, and I'd like each answer in a line.
- PaulA table with names on its columns is exactly what pandas is for.
census.csv has one row per person: year, parish, household, name, relation, age and occupation. The years are 1921, 1951, 1981 and 2011.
Write five functions. Each takes the whole census as a DataFrame, and leaves it as it was.
census_year(census, year): every row from that year, as a DataFrame.parish_count(census, year, parish): how many people lived in that parish that year.trade(census, year, occupation): a DataFrame of thename,parishandageof everyone in that occupation that year, oldest first.oldest(census, year): the name of the oldest person that year.parish_sizes(census, year): a Series of how many people lived in each parish that year, largest first.
The report at the bottom of the file is written for you.
Census of 1951: 98 people By parish: Bankside 35, Church Street 31, Hill 18, Northgate 14 On the Hill: 18 Fishermen: 6 Oldest of all: Walter Rook
What you learn
What's in it
- A table with names on its columns
- Rows, then columns
- Keep the rows that match
- Under forty
- Sorting and counting
- How many parishes?
- The census as a table
- Two conditions at once
- Two conditions
- Labels and positions
- Row nought
- How Paul would do it
- Make the census answers
- Ship it