Created
September 28, 2022 13:42
-
-
Save naenumtou/a46941ae978fd907f45c448a916bbcb3 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 spending price per period | |
df['TotalSale'] = df['Price'] * df['Quantity'] #Calculation total sale | |
dfPrice = df.groupby( | |
['cohortMonth', 'cohortIndex'], | |
as_index = False | |
)['TotalSale'].mean() | |
dfPrice = pd.pivot_table( | |
dfPrice, | |
values = 'TotalSale', | |
index = ['cohortMonth'], | |
columns = ['cohortIndex'] | |
) # Pivot | |
# Plot | |
plotTable(dfPrice, 'Total spending by month', percent = False) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment