The Most Profitable Holiday
Let's find out which exact holiday was the most profitable according to sales. To do this, we will need to replace the dates with respective labels of holidays, so that we can group by a certain holiday.
But all of the holidays have different dates in the data, so we need to perform a replacement first and then group by the new values.
We have gathered the dates and their respective holidays in the holidays_dates
dictionary (keys are dates, and values are the names of the holidays).
Swipe to start coding
- Replace the values in the
'Date'
column using theholidays_dates
dictionary. Overwrite the original dataframe. - Filter the data in the
df
DataFrame that satisfies the following conditions: these are holiday data (the'Holiday_Flag'
column is equal to1
) or'Pre-Christmas'
value within the'Date'
column. Save the resulting data in thedata
variable. - Group values in the
data
dataframe by the'Date'
column, select the'Weekly_Sales'
column, and calculate the mean and median of the chosen column.
Lösung
Danke für Ihr Feedback!
single
Fragen Sie AI
Fragen Sie AI
Fragen Sie alles oder probieren Sie eine der vorgeschlagenen Fragen, um unser Gespräch zu beginnen
Awesome!
Completion rate improved to 3.45
The Most Profitable Holiday
Swipe um das Menü anzuzeigen
Let's find out which exact holiday was the most profitable according to sales. To do this, we will need to replace the dates with respective labels of holidays, so that we can group by a certain holiday.
But all of the holidays have different dates in the data, so we need to perform a replacement first and then group by the new values.
We have gathered the dates and their respective holidays in the holidays_dates
dictionary (keys are dates, and values are the names of the holidays).
Swipe to start coding
- Replace the values in the
'Date'
column using theholidays_dates
dictionary. Overwrite the original dataframe. - Filter the data in the
df
DataFrame that satisfies the following conditions: these are holiday data (the'Holiday_Flag'
column is equal to1
) or'Pre-Christmas'
value within the'Date'
column. Save the resulting data in thedata
variable. - Group values in the
data
dataframe by the'Date'
column, select the'Weekly_Sales'
column, and calculate the mean and median of the chosen column.
Lösung
Danke für Ihr Feedback!
Awesome!
Completion rate improved to 3.45single