gilangw commited on
Commit
92584f3
·
1 Parent(s): ff5539c

Upload 2 files

Browse files
Files changed (1) hide show
  1. eda.py +3 -6
eda.py CHANGED
@@ -21,15 +21,12 @@ def run():
21
  # Plot 1
22
  def plot_1():
23
  st.write('#### Pie Chart for Customer Status Distribution')
24
- target = df["churn"].value_counts().reset_index()
25
- persen = df["churn"].value_counts(normalize=True).reset_index()
26
- #target["percentage"] = persen["churn"]
27
- print(target)
28
- print(persen)
29
 
30
  fig_1 = plt.figure()
31
  fig_1, ax = plt.subplots(ncols=1, figsize=(5, 5))
32
- ax.pie(target["percentage"], labels=target["index"], autopct='%.0f%%')
33
  ax.set_title("Customer Status Distribution")
34
  st.pyplot(fig_1)
35
  st.write('''
 
21
  # Plot 1
22
  def plot_1():
23
  st.write('#### Pie Chart for Customer Status Distribution')
24
+ target = df.groupby(['churn']).agg(total_churn=('churn', 'count'))
25
+ target['percentage'] = (target['total_churn'] / target['total_churn'].sum())
 
 
 
26
 
27
  fig_1 = plt.figure()
28
  fig_1, ax = plt.subplots(ncols=1, figsize=(5, 5))
29
+ ax.pie(target["percentage"], labels=target["percentage"].index, autopct='%.0f%%')
30
  ax.set_title("Customer Status Distribution")
31
  st.pyplot(fig_1)
32
  st.write('''