Skip to content

Instantly share code, notes, and snippets.

@karamanbk
Created May 25, 2019 09:35
Show Gist options
  • Save karamanbk/7f5d7aa3ab981b44ab22a8c020b0c6a8 to your computer and use it in GitHub Desktop.
Save karamanbk/7f5d7aa3ab981b44ab22a8c020b0c6a8 to your computer and use it in GitHub Desktop.
#Partner
df_plot = df_data.groupby('Partner').Churn.mean().reset_index()
plot_data = [
go.Bar(
x=df_plot['Partner'],
y=df_plot['Churn'],
width = [0.5, 0.5],
marker=dict(
color=['green', 'blue'])
)
]
plot_layout = go.Layout(
xaxis={"type": "category"},
yaxis={"title": "Churn Rate"},
title='Partner',
plot_bgcolor = 'rgb(243,243,243)',
paper_bgcolor = 'rgb(243,243,243)',
)
fig = go.Figure(data=plot_data, layout=plot_layout)
pyoff.iplot(fig)
#Phone Service
df_plot = df_data.groupby('PhoneService').Churn.mean().reset_index()
plot_data = [
go.Bar(
x=df_plot['PhoneService'],
y=df_plot['Churn'],
width = [0.5, 0.5],
marker=dict(
color=['green', 'blue'])
)
]
plot_layout = go.Layout(
xaxis={"type": "category"},
yaxis={"title": "Churn Rate"},
title='Phone Service',
plot_bgcolor = 'rgb(243,243,243)',
paper_bgcolor = 'rgb(243,243,243)',
)
fig = go.Figure(data=plot_data, layout=plot_layout)
pyoff.iplot(fig)
#Multiple Lines
df_plot = df_data.groupby('MultipleLines').Churn.mean().reset_index()
plot_data = [
go.Bar(
x=df_plot['MultipleLines'],
y=df_plot['Churn'],
width = [0.5, 0.5, 0.5],
marker=dict(
color=['green', 'blue', 'orange'])
)
]
plot_layout = go.Layout(
xaxis={"type": "category"},
title='Multiple Lines',
yaxis={"title": "Churn Rate"},
plot_bgcolor = 'rgb(243,243,243)',
paper_bgcolor = 'rgb(243,243,243)',
)
fig = go.Figure(data=plot_data, layout=plot_layout)
pyoff.iplot(fig)
#Internet Service
df_plot = df_data.groupby('InternetService').Churn.mean().reset_index()
plot_data = [
go.Bar(
x=df_plot['InternetService'],
y=df_plot['Churn'],
width = [0.5, 0.5, 0.5],
marker=dict(
color=['green', 'blue', 'orange'])
)
]
plot_layout = go.Layout(
xaxis={"type": "category"},
title='Internet Service',
yaxis={"title": "Churn Rate"},
plot_bgcolor = 'rgb(243,243,243)',
paper_bgcolor = 'rgb(243,243,243)',
)
fig = go.Figure(data=plot_data, layout=plot_layout)
pyoff.iplot(fig)
#Online Security
df_plot = df_data.groupby('OnlineSecurity').Churn.mean().reset_index()
plot_data = [
go.Bar(
x=df_plot['OnlineSecurity'],
y=df_plot['Churn'],
width = [0.5, 0.5, 0.5],
marker=dict(
color=['green', 'blue', 'orange'])
)
]
plot_layout = go.Layout(
xaxis={"type": "category"},
yaxis={"title": "Churn Rate"},
title='Online Security',
plot_bgcolor = "rgb(243,243,243)",
paper_bgcolor = "rgb(243,243,243)",
)
fig = go.Figure(data=plot_data, layout=plot_layout)
pyoff.iplot(fig)
#Online Backup
df_plot = df_data.groupby('OnlineBackup').Churn.mean().reset_index()
plot_data = [
go.Bar(
x=df_plot['OnlineBackup'],
y=df_plot['Churn'],
width = [0.5, 0.5, 0.5],
marker=dict(
color=['green', 'blue', 'orange'])
)
]
plot_layout = go.Layout(
xaxis={"type": "category"},
title='Online Backup',
plot_bgcolor = "rgb(243,243,243)",
paper_bgcolor = "rgb(243,243,243)",
)
fig = go.Figure(data=plot_data, layout=plot_layout)
pyoff.iplot(fig)
#Device Protection
df_plot = df_data.groupby('DeviceProtection').Churn.mean().reset_index()
plot_data = [
go.Bar(
x=df_plot['DeviceProtection'],
y=df_plot['Churn'],
width = [0.5, 0.5, 0.5],
marker=dict(
color=['green', 'blue', 'orange'])
)
]
plot_layout = go.Layout(
xaxis={"type": "category"},
title='Device Protection',
plot_bgcolor = "rgb(243,243,243)",
paper_bgcolor = "rgb(243,243,243)",
)
fig = go.Figure(data=plot_data, layout=plot_layout)
pyoff.iplot(fig)
#Tech Support
df_plot = df_data.groupby('TechSupport').Churn.mean().reset_index()
plot_data = [
go.Bar(
x=df_plot['TechSupport'],
y=df_plot['Churn'],
width = [0.5, 0.5, 0.5],
marker=dict(
color=['green', 'blue', 'orange'])
)
]
plot_layout = go.Layout(
xaxis={"type": "category"},
title='Tech Support',
plot_bgcolor = "rgb(243,243,243)",
paper_bgcolor = "rgb(243,243,243)",
)
fig = go.Figure(data=plot_data, layout=plot_layout)
pyoff.iplot(fig)
#Streaming TV
df_plot = df_data.groupby('StreamingTV').Churn.mean().reset_index()
plot_data = [
go.Bar(
x=df_plot['StreamingTV'],
y=df_plot['Churn'],
width = [0.5, 0.5, 0.5],
marker=dict(
color=['green', 'blue', 'orange'])
)
]
plot_layout = go.Layout(
xaxis={"type": "category"},
title='Streaming TV',
plot_bgcolor = "rgb(243,243,243)",
paper_bgcolor = "rgb(243,243,243)",
)
fig = go.Figure(data=plot_data, layout=plot_layout)
pyoff.iplot(fig)
#Streaming Movies
df_plot = df_data.groupby('StreamingMovies').Churn.mean().reset_index()
plot_data = [
go.Bar(
x=df_plot['StreamingMovies'],
y=df_plot['Churn'],
width = [0.5, 0.5, 0.5],
marker=dict(
color=['green', 'blue', 'orange'])
)
]
plot_layout = go.Layout(
xaxis={"type": "category"},
title='Streaming Movies',
plot_bgcolor = "rgb(243,243,243)",
paper_bgcolor = "rgb(243,243,243)",
)
fig = go.Figure(data=plot_data, layout=plot_layout)
pyoff.iplot(fig)
#Contract
df_plot = df_data.groupby('Contract').Churn.mean().reset_index()
plot_data = [
go.Bar(
x=df_plot['Contract'],
y=df_plot['Churn'],
width = [0.5, 0.5, 0.5],
marker=dict(
color=['green', 'blue', 'orange'])
)
]
plot_layout = go.Layout(
xaxis={"type": "category"},
title='Contract',
plot_bgcolor = "rgb(243,243,243)",
paper_bgcolor = "rgb(243,243,243)",
)
fig = go.Figure(data=plot_data, layout=plot_layout)
pyoff.iplot(fig)
#Paperless Billing
df_plot = df_data.groupby('PaperlessBilling').Churn.mean().reset_index()
plot_data = [
go.Bar(
x=df_plot['PaperlessBilling'],
y=df_plot['Churn'],
width = [0.5, 0.5, 0.5],
marker=dict(
color=['green', 'blue', 'orange'])
)
]
plot_layout = go.Layout(
xaxis={"type": "category"},
title='Paperless Billing',
plot_bgcolor = "rgb(243,243,243)",
paper_bgcolor = "rgb(243,243,243)",
)
fig = go.Figure(data=plot_data, layout=plot_layout)
pyoff.iplot(fig)
#Payment Method
df_plot = df_data.groupby('PaymentMethod').Churn.mean().reset_index()
plot_data = [
go.Bar(
x=df_plot['PaymentMethod'],
y=df_plot['Churn'],
width = [0.5, 0.5, 0.5,0.5],
marker=dict(
color=['green', 'blue', 'orange','red'])
)
]
plot_layout = go.Layout(
xaxis={"type": "category"},
title='Payment Method',
plot_bgcolor = "rgb(243,243,243)",
paper_bgcolor = "rgb(243,243,243)",
)
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