Skip to content

Homework 2

Instructions

Your solutions should be in form of a report in notebook (.ipynb) format, with a report that is easy to follow and understand, remember that Github has a builtin notebook interpreter. Make sure to document you procedure and segment the report properly. Make use of the markdown syntax to do this!

When you are finished push you results to Github and raise an issue, just as you have done in previous homework. To pass the homework you will have to complete the assigments below and also finish the peer-review.

Feel free to contact me if anything is unclear.

Setting up the repo

From homework 1 you should already have your repository set up. To begin with, create a .gitignore file in the root of you repository. Make sure that you ignore files that are unnecessary to the homework. Now, create a new folder, name it something along the lines of homework_2 or hw2. Remember to use _ instead of spaces between words.

After you are finished with the homework, make sure to push changes to your github.

Working with tables

The data for the assigments below can be found in the following repository on the Github repository

Apartment Prices

The data found in Booli_sold.csv contains data on sales of apartments in Ekhagen (next to Lappis). Download this file and read it into your code. Note that the data file is of type .csv. If you run in to some issue whilst reading in the data, use Google!

Your task is to

  1. Calculate the price per square meter (ppsqm) for each apartment sold. That is, add a new variable to your table containing the data representing the ppsqm.
  2. Rank the top 5 most expensive appartments w.r.t ppsqm. Present this in a table. Hint: Use a sort function.
  3. What is the avereage ppsqm in Ekhagen?
  4. Highlight an aspect of the data that you find interesting. Explain your choice.

The Swedish Election of 2018

The data found in 2018_R_per_kommun.csv contains data on voting in the 2018 Swedish election. Your job is to analyize the data by completeing the tasks below.

Note that csv files can have different seperators, delimeters and decimal signs. Take this into account when you are reading in this dataset. Your

Your task is to

  1. Calculate the total number of legitimate votes (Giltiga Röster) in Stockholm during the election. That is, sum upp the number of legitimate votes for all municipalities (kommun) in Stockholm.
  2. In which municipality did the social democratic party (Social demokraterna, S) garner the hightest voting percentage?
  3. Rank the (3) municipialities with highest participation (valdeltagande). Present this in the form of a table.

Predicting Strokes

In the file stroke-data.csv you can find data about stroke cases and information about the individuals it pertains. find out more about the dataset.

Your task is to draw a conclusion using a suitable plot. Choose something simple!