Final Challenge: Find the Day of Week with the Most Sales

Learn how to use the Pandas functions, fillna, groupby, dayofweek, and sort_values.

We'll cover the following

Problem Statement

This challenge consists of a few steps.

  1. We have a DataFrame called grocery, which contains some missing values in the price column. We need to fill them in with the average price of the product. For example, a missing price value for a tomato needs to be filled in with the average price of tomatoes.

  2. Then, we need to create a column called day_of_week by extracting the day-of-week information from the sales_date column. Make sure to convert the data type of the sales_date column to datetime64[ns].

  3. The final step is to calculate the average sales quantity on each day of the week. We need to sort the values in descending order and select the index of the first value to find the day of the week with the most sales.

Solution

Write your solution in the specified place and click on “test”.

  • Make sure to uncomment the lines before execution.

Get hands-on with 1200+ tech skills courses.