From the course: Python Data Analysis

Unlock the full course today

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

Yearly top ten names

Yearly top ten names - Python Tutorial

From the course: Python Data Analysis

Start my 1-month free trial

Yearly top ten names

- [Instructor] In this video, we will create yearly top 10s for male and female names. We load the data, and this time, we index it slightly differently, by sex and year only since we will need to compare all the names in the database. We now build up a query by chaining pandas methods. Getting males in 2018 is a simple matter of a multiindex.log. Then we get the most popular names by sorting our number in descending order. Head gives us a top 10. In 2018, Liam was king, followed closely by Noah. How about girls? We index sex with f, and the year is still 2018. For girls, it was Emma and Olivia. If we to build a table of the top 10 names over multiple years, we should get rid of the index with Reset Index, and select the name, Column Only. I will make this into a generic function. As I was saying, in pandas, one sees this operator chaining style often. And we can make the code clear by giving each method it's own…

Contents