TDM 10100: Project 3 Question 1 examples

For example, in Project 1, Question 4, we learned about the ice cream combined reviews data, stored here:

/anvil/projects/tdm/data/icecream/combined/reviews.csv

In the video below, we look at the names of the authors of the reviews. In particular, please notice that, for 800 of the reviews, the author is empty, and for 177 of the reviews, Anonymous is given as the name of the author. We are using R in this example:

As another example, we have already learned how to load the airport data from this data set:

/anvil/projects/tdm/data/flights/subset/airports.csv

in R back in Project 1. You may remember already reading how to load this data in R:

You can also load the same airport data set in Python, and display the head of the airports data set.

import pandas as pd
myDF = pd.read_csv("/anvil/projects/tdm/data/flights/subset/airports.csv")
myDF.head()

Just try this Python code using the seminar kernel (not the seminar-r kernel) and make sure that you can see the first five rows of the airports data frame.

Now we learn how to identify the values that occur repeatedly, in a column of a data frame. For our example, we will study which state has the largest number of airports. (We will not pay attention to the city, in this example.) How many airports are located in that state? We can figure this out, by writing:

myDF['state']

and then the value_counts function gives the number of airports in each state:

myDF['state'].value_counts()

Finally, we can make a plot of the value counts for the airports example!