Last active
March 31, 2020 01:22
-
-
Save karamanbk/c1e521e0cd537e829526c0a02543b29d 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
tx_merge = pd.merge(tx_user, tx_user_6m, on='CustomerID', how='left') | |
tx_merge = tx_merge.fillna(0) | |
tx_graph = tx_merge.query("m6_Revenue < 30000") | |
plot_data = [ | |
go.Scatter( | |
x=tx_graph.query("Segment == 'Low-Value'")['OverallScore'], | |
y=tx_graph.query("Segment == 'Low-Value'")['m6_Revenue'], | |
mode='markers', | |
name='Low', | |
marker= dict(size= 7, | |
line= dict(width=1), | |
color= 'blue', | |
opacity= 0.8 | |
) | |
), | |
go.Scatter( | |
x=tx_graph.query("Segment == 'Mid-Value'")['OverallScore'], | |
y=tx_graph.query("Segment == 'Mid-Value'")['m6_Revenue'], | |
mode='markers', | |
name='Mid', | |
marker= dict(size= 9, | |
line= dict(width=1), | |
color= 'green', | |
opacity= 0.5 | |
) | |
), | |
go.Scatter( | |
x=tx_graph.query("Segment == 'High-Value'")['OverallScore'], | |
y=tx_graph.query("Segment == 'High-Value'")['m6_Revenue'], | |
mode='markers', | |
name='High', | |
marker= dict(size= 11, | |
line= dict(width=1), | |
color= 'red', | |
opacity= 0.9 | |
) | |
), | |
] | |
plot_layout = go.Layout( | |
yaxis= {'title': "6m LTV"}, | |
xaxis= {'title': "RFM Score"}, | |
title='LTV' | |
) | |
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