Created
December 26, 2023 06:59
-
-
Save smzn/f1a41feae17a7b3d720b9442c7dbf430 to your computer and use it in GitHub Desktop.
Counting the number of each top item sold each day
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Identifying the items that make up 80% of total sales | |
top_items = item_sales_counts.cumsum().sort_values(ascending=False) | |
top_items = top_items[top_items <= eighty_percent_threshold].index | |
# Filtering data for only the top items | |
filtered_data = bakery_data[bakery_data['Items'].isin(top_items)] | |
# Counting the number of each top item sold each day | |
daily_top_item_sales = filtered_data.groupby(['Date', 'Items']).size().unstack(fill_value=0) | |
# Merging the daily top item sales with the daily total sales | |
combined_top_items_daily = daily_top_item_sales.join(daily_item_count.rename('Total_Daily_Sales')) | |
# Calculating the correlation matrix for this data | |
correlation_matrix_top_items_daily = combined_top_items_daily.corr() | |
# Plotting the heatmap of the correlation matrix | |
plt.figure(figsize=(12, 10)) | |
sns.heatmap(correlation_matrix_top_items_daily, annot=True, cmap='coolwarm') | |
plt.title('Correlation Matrix of Top Item Sales per Day and Total Daily Sales') | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment