-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
62 lines (44 loc) · 1.4 KB
/
Copy pathmain.py
File metadata and controls
62 lines (44 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import pandas as pd
import os
table = pd.read_csv("cancelamentos_sample.csv")
table = table.drop(columns="CustomerID")
table.dropna()
column_cancelou = table["cancelou"]
print("Pre-resolution: ")
print(column_cancelou.value_counts(normalize=True).map("{:.0%}".format))
import plotly.express as px
import os
output_dir = "pre-resolution"
os.makedirs(output_dir, exist_ok=True)
for column in table.columns:
graph = px.histogram(
table,
x=column,
color="cancelou",
category_orders={"cancelou": [0, 1]},
color_discrete_map={1: "red", 0:"green"},
text_auto=True,
)
graph.write_image(f"{output_dir}/{column}.png")
condition = table["idade"] <= 50
table = table[condition]
condition = table["ligacoes_callcenter"] <= 4
table = table[condition]
condition = table["duracao_contrato"] != "Monthly"
table = table[condition]
condition = table["dias_atraso"] <= 15
table = table[condition]
output_dir = "post-resolution"
os.makedirs(output_dir, exist_ok=True)
for column in table.columns:
graph = px.histogram(
table,
x=column,
color="cancelou",
category_orders={"cancelou": [0, 1]},
color_discrete_map={1: "red", 0:"green"},
text_auto=True,
)
graph.write_image(f"{output_dir}/{column}.png")
print("Post-resolution: ")
print(table["cancelou"].value_counts(normalize=True).map("{:.0%}".format))