Homework 3-1


In this homework assignment, you will get to use the same data you worked with in the activity!

The dataset contains happiness data on countries worldwide. If you haven't done so already, download the csv file here and save it in your CS 3 workspace.

The happiness statistic in the data set is a sum of all of the other attributes (Economy, Family, Health, Freedom, Trust, Generosity, Dystopia). In this homework assignment you will use pandas and data frames in your own program that will generate your own happiness statistic, rank countries based on your statistic, and explore changes with the new data set.

Task 1:

Using the attributes from the data set, divise your own happiness statistic. One way to create a new statistic is computing a weighted sum of the different attributes. You can weight factors you think are more important heavier than factors that are less important. This is a more effective way to determine a rating than simply taking the sum of different attributes. In your program, write a 1-2 sentence comment justifying the choices you made for your new statistic.

Task 2:

Now, you should have a data frame with two statistics: the initial happiness rating and your new happiness rating. Use this data to answer the following questions:

  1. Based on your new ranking: What are the 10 happiest countries?
  2. Based on your new ranking: What are the 10 least happy countries?
  3. How do countries rank within their respective regions? (Hint: Use a query to find out!)
  4. How have the rankings you calculated in steps 1-3 changed between your new statistic and the old statistic?
  5. Use what you know about pandas to answer a single question of your own chosing about this data set.

At the top of your assignment, please comment how many hours you worked on this assignment, people you worked with, whether you went to TA hours for help or clarification on this assignment.

Make sure your submission has your name in the filename: FirstLast_HW3-2.py. “FirstLast” should be replaced with your first and last name or we will take off points. Make sure every task has been completed.