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.
-
We have a
DataFrame
calledgrocery
, which contains some missing values in theprice
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. -
Then, we need to create a column called
day_of_week
by extracting the day-of-week information from thesales_date
column. Make sure to convert the data type of thesales_date
column todatetime64[ns]
. -
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 1400+ tech skills courses.