From the course: pandas Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Solution

Solution - pandas Tutorial

From the course: pandas Essential Training

Start my 1-month free trial

Solution

- [Instructor] Okay, so let's get started on the stack and unstack challenge questions and remember that this is just the way I'm going to solve them. There are multiple ways of solving these problems. So, let's import pandas as pd. Root in the data into our data frame. Now, we want to plot the number of gold medals won by USA male and female athletes throughout the history of the Olympics. So, the first thing we want to do is to determine which athletes are from the USA so, oo.NOC equals USA and because we're going to have more than one condition we include the conditions in parentheses and we want the athletes that have won a gold medal so, oo.Medal equals Gold. And let's store that in the data frame gu for gold. And let's confirm that this data frame has the information we want. So, the athletes are all from the USA, we can see that in terms of gender there's both male and female athletes. All of them have won gold medals and so we're good to go. Now the next thing is because we…

Contents