Created
May 4, 2019 09:20
-
-
Save karamanbk/aa87cbf05cfd69bf823f1f25a1a0b502 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 and create a new dataframe for it | |
tx_6m['Revenue'] = tx_6m['UnitPrice'] * tx_6m['Quantity'] | |
tx_user_6m = tx_6m.groupby('CustomerID')['Revenue'].sum().reset_index() | |
tx_user_6m.columns = ['CustomerID','m6_Revenue'] | |
#plot LTV histogram | |
plot_data = [ | |
go.Histogram( | |
x=tx_user_6m.query('m6_Revenue < 10000')['m6_Revenue'] | |
) | |
] | |
plot_layout = go.Layout( | |
title='6m Revenue' | |
) | |
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