Skip to content

About

Python-based customer retention and churn analysis using e-commerce transactional data. The project applies cohort analysis, churn proxies, and revenue segmentation to uncover repeat purchase behavior and its impact on long-term revenue.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

1. Business Context

Customer acquisition is costly, and sustainable business growth depends on retaining existing customers and encouraging repeat purchases. Many organizations, however, lack clear visibility into when and why customers stop purchasing and how retention behavior evolves over time.

This project uses pure Python-based data analysis to study customer retention patterns, identify churn behavior, and quantify the revenue impact of repeat customers. The objective is to generate actionable, data-driven insights that can help businesses improve retention strategies and increase Customer Lifetime Value (CLV).


2. Business Problems Addressed

Customer Retention

  • How many customers return to make repeat purchases?
  • How frequently do customers purchase after their first order?
  • How does retention change across different customer cohorts?

Churn Identification

  • When should a customer be considered churned in the absence of explicit labels?
  • How long do customers typically remain active before stopping purchases?
  • What proportion of customers can be classified as churned?

Revenue Contribution

  • How much revenue is generated by repeat customers versus one-time buyers?
  • Which customer groups contribute most to long-term revenue?

3. Dataset Overview

Source: Kaggle — Olist Brazilian E-commerce Dataset

Datasets Used

  • Customers dataset
  • Orders dataset
  • Order payments dataset

Key Fields

  • customer_unique_id: Unique identifier for customers
  • order_id: Unique identifier for orders
  • order_purchase_timestamp: Timestamp of order purchase
  • payment_value: Total payment value of an order

The dataset represents real-world transactional behavior from a large Brazilian e-commerce platform.


4. Tools & Technologies Used

This project is implemented using pure Python for data analysis and visualization:

  • Python
  • pandas – data manipulation and aggregation
  • NumPy – numerical computations
  • Matplotlib – data visualization

No SQL, BI tools, or external analytics platforms were used.


5. Analysis Pipeline

Raw CSV Data
→ Data Loading with pandas
→ Data Cleaning & Feature Engineering
→ Exploratory Data Analysis (EDA)
→ Retention, Churn & Cohort Analysis
→ Visualization using Matplotlib

6. Retention & Churn Definitions

Repeat Customer

A customer who has placed more than one completed order.

Churn (Proxy Definition)

A customer is considered churned if:

Days since last purchase > 90 days

This proxy reflects common industry practice when explicit churn labels are unavailable.


7. Analysis Methodology

First-Time vs Repeat Buyers

  • Customers were segmented based on total completed orders
  • Repeat purchase rate was calculated

Time Between Purchases

  • Purchase intervals were computed using order timestamps
  • Distribution of days between consecutive purchases was analyzed

Cohort Analysis

  • Customers were grouped by their first purchase month
  • Month-over-month retention was tracked for each cohort

Revenue Contribution Analysis

  • Revenue was segmented into one-time and repeat customers
  • Revenue contribution percentages were calculated and compared

8. Key Insights

  • A large proportion of customers make only a single purchase
  • Retention drops sharply after the first purchase window
  • Repeat customers contribute a disproportionately high share of total revenue
  • Most churn occurs within the first few months after the initial purchase

9. Business Impact

This analysis helps businesses:

  • Identify critical drop-off points in the customer lifecycle
  • Focus retention strategies on high-risk time periods
  • Prioritize repeat customers for long-term revenue growth
  • Make data-driven decisions to improve customer loyalty

10. Deliverables

  • Cleaned and feature-engineered pandas DataFrames

  • Retention, churn, and cohort metrics computed in Python

  • Visualizations created using Matplotlib, including:

    • Retention trends
    • Cohort retention heatmaps
    • Revenue contribution comparisons

11. Limitations & Future Improvements

Limitations

  • Churn is defined using a time-based proxy rather than explicit labels
  • No demographic, marketing, or product-level features were included

Future Improvements

  • Segment retention by geography or product category
  • Implement Customer Lifetime Value (CLV) modeling
  • Apply survival analysis for more robust churn prediction

12. Conclusion

This project demonstrates how pure Python-based data analysis can transform raw transactional data into meaningful customer retention insights. By applying cohort analysis, churn proxies, and revenue attribution, the project provides a clear understanding of customer behavior and highlights opportunities to improve long-term business performance.

About

Python-based customer retention and churn analysis using e-commerce transactional data. The project applies cohort analysis, churn proxies, and revenue segmentation to uncover repeat purchase behavior and its impact on long-term revenue.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages