From the course: Introduction to Data Science
Unlock this course with a free trial
Join today to access over 24,900 courses taught by industry experts.
Interpreting tabular data
From the course: Introduction to Data Science
Interpreting tabular data
Imagine I have a data set that has information on baby names for each state in the US. Notice that each row represents a distinct set of baby name, birth year, and birth state. Now, let's use pandas and the states underscore babies data set to answer the following question. What were the five most popular baby names in 2014 in California? In this lesson, I'll show you how to do this using the Pandas library. As a reminder, this is what the state's babies data frame looks like. Now, the first thing I want to do is slice out the rows for the year 2014. So I'll use the loc method. The first input indicates that I want only the rows of the states baby's data frame that correspond to names of babies born in various states in the year 2014. The second input indicates that I want all columns for the aforementioned rows. And since the loc method returns a new data frame, I'll go ahead and store it in a variable which I'll name, "states_babies_2014." And I'll run the cell now. Now, I'll type…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.