From the course: Introduction to Data Science

Unlock this course with a free trial

Join today to access over 23,200 courses taught by industry experts.

Gathering insights

Gathering insights

Let's use pandas and the states_babies data set to answer the following question. "What were the most popular female and male baby names in California in each year?" Now, I'll show you how to do this using the Pandas library. As a reminder, the loc method allows you to access a specific group of rows and columns from a Pandas data frame, and the method receives two inputs. The first input describes which rows to take from the data frame, and the second input describes which columns to take from the data frame. And loc returns a new data frame containing the rows and columns you specified So I'll type in ca_babies = states_babies.loc [state_babies['state'] = = CA , :] And I'll go ahead and run the cell. This specifies that I only want the rows of the states babies data set where state is California and the colon specifies that I want all the columns for those rows. So now I'll type in ca_babies and hit "Run." There we go. Now, I'll show you how to group the CA babies data frame by both…

Contents