Spaces:
Sleeping
Sleeping
Upload 2 files
Browse files
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[
|
| 25 |
-
|
| 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["
|
| 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('''
|