TDM 10100: Project 4 Question 1 examples
If you want to learn more about Pandas, this is the home page:
Here are some examples about reading data into Pandas data frames:
Example 1
We read data into a Pandas data frame in the steps below, first by loading Pandas:
import pandas as pd
and then reading in the Pandas data frame:
myDF = pd.read_csv("/anvil/projects/tdm/data/icecream/combined/reviews.csv")
Now we can check that we read it in properly:
myDF.head()
and we can even summarize a column to be sure:
myDF['brand'].value_counts()
Example 2
Once we have imported Pandas in our current session, we do not need to re-import it. We can just read in more data frames, e.g., like this:
myDF = pd.read_csv("/anvil/projects/tdm/data/flights/subset/airports.csv")
Now we can check that we read it in properly:
myDF.head()
and we can even check which states have the most airports. Please note that the value_counts are sorted by default:
myDF['state'].value_counts()