Topics in this subject
Pandas 1 min read Updated 4 Aug 2026

Project 7 — Customer Churn Analysis

cust = pd.DataFrame({

cust = pd.DataFrame({
    'customer':[1,2,3,4,5],
    'tenure_months':[2,24,5,36,1],
    'monthly_charge':[70,50,90,40,80],
    'churned':[1,0,1,0,1]})

# Churn rate overall
cust['churned'].mean()                       # 0.6

# Tenure buckets vs churn
cust['tenure_bucket'] = pd.cut(cust['tenure_months'], [0,6,12,60],
                               labels=['0-6','6-12','12+'])
cust.groupby('tenure_bucket')['churned'].mean()

# Correlation of numeric drivers with churn
cust[['tenure_months','monthly_charge','churned']].corr()['churned']

Insight: short tenure + high charges correlate with churn — groupby on binned tenure + corr surface the drivers.