Transforming Data With Pandas
In this lesson, we’ll continue working with the World Happiness Report and explore another aspect of it that we haven’t analyzed yet – the factors that contribute to happiness. As a reminder, the World Happiness Report assigns each country a happiness score based on a poll question that asks respondents to rank their life on a scale of 0 to 10.
Throughout this lesson, we’ll explore how to transform data using pandas. To facilitate your exploration of transforming data with pandas, you’ll work to answer the following question in this lesson:
- Which of the factors that contribute to happiness contribute the most to the happiness score?
In order to answer this question, we need to manipulate our data into a format that makes it easier to analyze. We’ll explore the following functions and methods to perform this task:
As you work through each concept in this lesson, you’ll get to apply what you’ve learned from within your browser so that there’s no need to use your own machine to do the exercises. The Python environment inside of this course includes answer checking so you can ensure that you’ve fully mastered each concept before learning the next concept.
- Learn how to apply custom functions to transform columns in pandas.
- Learn how to reshape data to prepare it for analysis.
- Apply a Function Element-wise Using the Map and Apply Methods
- Apply a Function Element-wise Using the Map and Apply Methods Continued
- Apply a Function Element-wise to Multiple Columns Using Applymap Method
- Apply Functions along an Axis using the Apply Method
- Apply Functions along an Axis using the Apply Method Continued
- Reshaping Data with the Melt Function
- Challenge: Aggregate the Data and Create a Visualization
- Next steps