Lab 4: groupby():

Description: Create a new Jupyter Notebook file. Download the zip file containing tips.csv. Extract it and read the data into a pandas DataFrame. Use the skills that were introduced in exercises 3.6 and 3.7 to create DataFrames similar to the below in parts 1 and 2. Submit screengrabs of each DataFrame containing the output, similar to the screenshots below.

  • Each question should result in a DataFrame that contains only the given number of rows.

Part 1: Do the data wrangling required to get this dataframe:

  • Hint: to calculate the tip_percentage, divide df['tip'] by df['total_bill']

Expected output: tips.csv DataFrame with tip_percentage column added after data wrangling

 

Part 2: Do the data wrangling required to answer the following three questions below by using the DataFrame created in Part 1.

  1. Question 1: Do you earn more tips (on average) for dinner or lunch?

Expected output: tips DataFrame grouped by meal time showing average tip for dinner vs lunch

 

  1. Question 2: Do you earn a lower (average) tip percent for larger size parties?

Expected output: tips DataFrame grouped by party size showing average tip percentage per party size

 

  1. Question 3: Do you get better tips on some days vs others?

Expected output: tips DataFrame grouped by day of week showing average tip per day