I've been hearing a lot that this past election was the PC party's to lose, and that what we saw was not an "Orange Crush" as much as an ABC -- Anything But Conservative. I'm not sure entirely how you would test this with data, but one I think I could do is look at who is the biggest loser.
This is also an excuse to break out
geopandas and start making maps! Hooray maps! As with before I loaded the election data straight from the Alberta elections website and processed it. I indexed the table by election district number this time, just for convenience. Then I processed the data with the addition of who was the runner up.
The results of this is a table with the votes for each party, the total number of votes, the difference between the winner and the next runner up, which party was the winner, which party was the runner up, and if we lived in a two-party state which party would win.
Super conveniently, Alberta elections has a shapefile for all the election districts which you can download. Unfortunately for later the shapefile is in some weird I don't know what and not latitude and longitude (I know nothing about GIS y'all!) so it isn't straight forward to make a google map or something (or maybe it is? I know nothing about GIS y'all!). I load this as another dataframe, and again I index it by election district number.
Now I know that row 1 of the election results corresponds to row 1 of the shape data. This is handy.
I can make a nice rainbow plot of the election districts using
matplotlib, hey that's my home province!
Now I can walk through my table of election results and colour code a map based on who won, I don't know if my colours are the party colours, I just picked them by eye as being "orange" or "blue".
But who were the biggest losers?
I can just as well make a map of all the runners up. There's a lot of blue on that map.
As you can see from the bar-charts below, the PC party was the biggest loser, the runner up in the most ridings. Which really drives home that the PC base did not desert them completely, just that enough not conservatives showed up and that sealed the deal.
Finally, for completeness here's what it would have looked like if the NDP had absorbed all the left wing parties and the PCs all the right wing parties (well, the Wildrose party). The NDP would have still done well in Edmonton and Calgary, but the province would have been solidly blue once more.
Broadly it appears that the cities were a battle mostly between the NDP and PCs, and the rural ridings, well, mostly PC/WRP except in the north where the NDP made a good showing.