-
-
Save amankharwal/832816c0e9fc28e7c1404a8b97f75e73 to your computer and use it in GitHub Desktop.
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
#Average quantity for each cohort | |
grouping = df.groupby(['CohortMonth', 'CohortIndex']) | |
cohort_data = grouping['Quantity'].mean() | |
cohort_data = cohort_data.reset_index() | |
average_quantity = cohort_data.pivot(index='CohortMonth',columns='CohortIndex',values='Quantity') | |
average_quantity.round(1) | |
average_quantity.index = average_quantity.index.date | |
#Build the heatmap | |
plt.figure(figsize=(15, 8)) | |
plt.title('Average quantity for each cohort') | |
sns.heatmap(data=average_quantity,annot = True,vmin = 0.0,vmax =20,cmap="BuGn_r") | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment