election
is a small Rust program for processing vote data from Canadian Federal Elections.
After building, see election --help
for the available options.
Federal election data can be found here. election
currently only supports 2019.
2021 will be supported as soon as the data is made public. To get the 2019 data,
navigate as follows:
- 43rd General Election, October 21, 2019
- Go to the raw data version (for researchers)
- Canada / Provinces / Territories
- Canada (Poll-by-poll Results - Format 2)
You must use the Format 2 data.
Download this data and unzip its contents into data/2019/
within your clone of
this repository.
All results are output as JSON. I use another tool, Nushell, to format the results into nice tables.
For example, to see how the Rhinoceros Party (a joke party) did in each riding:
cargo run --release -- --party=rin | from json | reverse | first 10
ββββ¬βββββββββββββββββββββββββββββββββββββ¬ββββββββ¬ββββββββββββββββββββββ¬ββββββββββββββββ¬ββββββββ¬βββββββββ¬βββββββ # β riding β party β last_name β first_name β votes β ratio β won ββββΌβββββββββββββββββββββββββββββββββββββΌββββββββΌββββββββββββββββββββββΌββββββββββββββββΌββββββββΌβββββββββΌβββββββ 0 β Beauce β Rhino β Bernier β Maxime β 1084 β 0.0182 β false 1 β GaspΓ©sie--Les Γles-de-la-Madeleine β Rhino β Cowboy β Jay β 353 β 0.0091 β false 2 β Calgary Signal Hill β Rhino β Bassett β Christina β 511 β 0.0080 β false 3 β Papineau β Rhino β Cacereco Berthiaume β Jean-Patrick β 363 β 0.0071 β false 4 β Chicoutimi--Le Fjord β Rhino β BΓ©langer β Line β 299 β 0.0068 β false 5 β QuΓ©bec β Rhino β CoRhino β SΓ©bastien β 349 β 0.0064 β false 6 β Hochelaga β Rhino β Blais-Leduc β Chinook β 314 β 0.0059 β false 7 β Rosemont--La Petite-Patrie β Rhino β Lavoie β Jos Guitare β 346 β 0.0057 β false 8 β MΓ©gantic--L'Γrable β Rhino β Roy β Damien β 256 β 0.0053 β false 9 β LaSalle--Γmard--Verdun β Rhino β BΓ©langer β Rhino Jacques β 265 β 0.0050 β false ββββ΄βββββββββββββββββββββββββββββββββββββ΄ββββββββ΄ββββββββββββββββββββββ΄ββββββββββββββββ΄ββββββββ΄βββββββββ΄βββββββ
The big parties have many more candidates than won seats. If we want to see just the victorious seats:
cargo run --release -- --party=grn | from json | where won | reverse
ββββ¬ββββββββββββββββββββββββ¬ββββββββββββββ¬ββββββββββββ¬βββββββββββββ¬ββββββββ¬βββββββββ¬ββββββ # β riding β party β last_name β first_name β votes β ratio β won ββββΌββββββββββββββββββββββββΌββββββββββββββΌββββββββββββΌβββββββββββββΌββββββββΌβββββββββΌββββββ 0 β Saanich--Gulf Islands β Green Party β May β Elizabeth β 33454 β 0.4908 β true 1 β Nanaimo--Ladysmith β Green Party β Manly β Paul β 24844 β 0.3457 β true 2 β Fredericton β Green Party β Atwin β Jenica β 16640 β 0.3367 β true ββββ΄ββββββββββββββββββββββββ΄ββββββββββββββ΄ββββββββββββ΄βββββββββββββ΄ββββββββ΄βββββββββ΄ββββββ
Or perhaps we wish to see how every party did overall:
cargo run --release -- --total | from json | sort-by votes | reverse
βββββ¬ββββββββββββββββββββββββββββββββ¬ββββββββββ¬βββββββββ¬βββββββ # β party β votes β ratio β seats βββββΌββββββββββββββββββββββββββββββββΌββββββββββΌβββββββββΌβββββββ 0 β Conservative β 6239227 β 0.3433 β 121 1 β Liberal β 6018728 β 0.3312 β 157 2 β New Democratic Party β 2903722 β 0.1598 β 24 3 β Bloc QuΓ©bΓ©cois β 1387030 β 0.0763 β 32 4 β Green Party β 1189607 β 0.0654 β 3 5 β People's Party β 294092 β 0.0161 β 0 6 β Independent β 72546 β 0.0039 β 1 7 β Christian Heritage Party β 18901 β 0.0010 β 0 8 β Rhinoceros Party β 9538 β 0.0005 β 0 9 β Libertarian β 8367 β 0.0004 β 0 10 β Veteran's Coalition β 6300 β 0.0003 β 0 11 β Animal Protection Party β 4408 β 0.0002 β 0 12 β Marxist-Leninist β 4124 β 0.0002 β 0 13 β Communist β 3905 β 0.0002 β 0 14 β Pour l'IndΓ©pendance du QuΓ©bec β 3815 β 0.0002 β 0 15 β No Affiliation β 1745 β 0.0000 β 0 16 β PC Party β 1534 β 0.0000 β 0 17 β Radical Marijuana β 920 β 0.0000 β 0 18 β Canada's Fourth Front β 682 β 0.0000 β 0 19 β United Party of Canada β 602 β 0.0000 β 0 20 β National Citizens Alliance β 510 β 0.0000 β 0 21 β Stop Climate Change β 296 β 0.0000 β 0 22 β Nationalist β 281 β 0.0000 β 0 βββββ΄ββββββββββββββββββββββββββββββββ΄ββββββββββ΄βββββββββ΄βββββββ