Scraping Data from a Single Vote
Learn how to scrape data from a single vote using Pandas data frame.
We'll cover the following
A democratic parliament means the people of that country vote for their choice of leader, and whoever with the majority of votes wins. For this lesson, we will be looking at the data for Canadian voting statistics.
We will see how often parliament members vote strictly along party lines. If they’re always following their party leaders, then it would seem that they’re serving their parties. If, on the other hand, they often cast votes independently of their parties, then they might be thinking more about their own constituents.
This won’t definitively prove anything one way or the other, but if we can access a large enough dataset, we should be able to draw some interesting insights.
We’ll begin on a web page managed by the House of Commons itself. The OurCommons API expects you to play around with URLs based on the base address, ourcommons.ca/Members/
. Adding en
tells the server that you want the service in English. Adding a forward slash and then the word votes, /votes
, means that you’re looking for voting records.
Some of the terms we need to be familiar with while analyzing this data are:
- Parliament: A parliament in this context is all the sittings between forming a new government after one election until its dissolution before the next election.
- Session: A session is a few months’ (or even years’) worth of sittings.
What’s the difference between members and government bills? The former is sponsored by regular members of parliament of any party, while the latter is always sponsored by cabinet ministers and reflects the government’s official position.
Create a free account to view this lesson.
By signing up, you agree to Educative's Terms of Service and Privacy Policy