The fourth tutorial is reviewing and learning functions useful for being an analyst that not have already been covered. The questions are based on a wine quality data set.
Note: At PandasZoo we use single quotes for our answers.
This is a sample of what the data set looks like:
|fixed acidity||volatile acidity||citric acid||residual sugar||chlorides||free sulfur dioxide||total sulfur dioxide||density||pH||sulphates||alcohol||quality|
Import the Pandas module.
Hint: We put in an example answer that you should try typing in.
Read in the wine quality data set. No need for a full path. The file is called winequality-red.csv
When you read in the data and make a dataframe object, call it wine.
Hint: We refer to Pandas as pd. You can find official documentation for read_csv here
Use the head function to look at the wine DataFrame.
Sort the wine DataFrame by alcohol where ascending is false. Overwrite the wine DataFrame with this sorting.
Dang, there is wine out there that is 14% or higher, let's make a column for anything greater than or equal to 14% and call the column strong_wine.
Make the new column have a true/false, so no need for any if logic.
Hint, the data is already multipled by 100
Let's take a look at wines that are True for the 'strong_wine' column and have a pH of 3.68. Use the head function to see these.
Let's use regex filtering to look at only the pH column.
Use the head function so we don't need to save an object.
Let's use seaborn to plot quality on the x axis and alcohol on the y axis. Make a linear fit using
lmplot is the function we want to use.
Hint: Assume I ran the follwing code already:
import seaborn as sns