Created
May 3, 2019 20:18
-
-
Save karamanbk/f187125f093e199e444a68fa3ad33c45 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#calculate revenue for each customer | |
tx_uk['Revenue'] = tx_uk['UnitPrice'] * tx_uk['Quantity'] | |
tx_revenue = tx_uk.groupby('CustomerID').Revenue.sum().reset_index() | |
#merge it with our main dataframe | |
tx_user = pd.merge(tx_user, tx_revenue, on='CustomerID') | |
#plot the histogram | |
plot_data = [ | |
go.Histogram( | |
x=tx_user.query('Revenue < 10000')['Revenue'] | |
) | |
] | |
plot_layout = go.Layout( | |
title='Monetary Value' | |
) | |
fig = go.Figure(data=plot_data, layout=plot_layout) | |
pyoff.iplot(fig) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment