Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Customer Data Preprocessing and Analysis

Cleaning, restructuring, and exploratory analysis of 1,000 customer records — pure-Python preprocessing (CSV → nested JSON) plus a pandas/seaborn EDA with 12 figures and summary tables.

Python pandas seaborn License: MIT

Tech stack & skills: Python (standard library: csv, json, math) · pandas · Matplotlib · seaborn — covering data loading & parsing, data cleaning, missing-value handling, CSV→nested-JSON restructuring, feature encoding, and exploratory data analysis with summary statistics and visualizations.

Preprocess and analyze customer records (including credit-card details) using pure Python for the cleaning stage and pandas / seaborn for the analysis stage. The pipeline loads raw CSV data, restructures it into nested JSON, corrects errors, handles missing values, and produces a full set of summary tables and visualizations to prepare the data for further modeling.

Project Structure

Customer-Data-Preprocessing-and-Analysis/
├── README.md
├── LICENSE
├── requirements.txt
├── customer_data_preprocessing.ipynb   # main notebook
├── Data/
│   └── acw_user_data.csv               # input dataset
├── Figures/                            # generated plots (embedded below)
├── Tables/                             # generated summary tables (CSV + Markdown)
└── Results/                            # generated JSON (created on run)

What the Notebook Does

Stage 1 — Preprocessing (standard library only)

  • Reads the raw CSV with the csv module.
  • Restructures flat rows into a nested record format (vehicle, credit card, and address grouped into sub-objects).
  • Flags problematic rows (e.g. missing dependants).
  • Writes processed.json, and splits records into retired.json and employed.json.
  • Flags credit cards whose validity span exceeds 10 years into removed_card.json.
  • Computes a salary-per-commute-mile metric and writes a sorted commute.json.

Stage 2 — Analysis (pandas / seaborn)

  • Summary statistics, univariate and multivariate plots.
  • An extended EDA section generating the tables and figures shown below.

All generated files are written to Results/, Figures/, and Tables/.

Requirements

  • Python 3.9+
  • Packages listed in requirements.txt (pandas, seaborn, matplotlib, notebook)

Setup and Run

Option 1 — Locally with Jupyter

# 1. (optional) create a virtual environment
python -m venv .venv
source .venv/bin/activate        # on Windows: .venv\Scripts\activate

# 2. install dependencies
pip install -r requirements.txt

# 3. launch Jupyter
jupyter notebook

Then open customer_data_preprocessing.ipynb and run the cells top to bottom.

Option 2 — Google Colab

  1. Upload customer_data_preprocessing.ipynb to Google Colab.
  2. Upload acw_user_data.csv when prompted (or mount Google Drive) into a Data/ folder.
  3. Run each cell in order.

Summary Tables

Numeric Summary Statistics

count mean std min 25% 50% 75% max
Age (Years) 1000 54.3 21.32 18 36 54 72 91
Yearly Salary (GBP) 1000 57814.1 23270.4 17046 39089.8 57518 77211.5 98915
Yearly Pension (GBP) 1000 5875.41 10986.5 0 0 0 0 46117
Distance Commuted to Work (miles) 1000 10.46 6.95 0 5.64 12.17 16.26 20.34
Dependants 1000 2.13 0.97 1 1 2 3 5
Vehicle Year 1000 2006.93 8.21 1992 2000 2008 2014 2020

Missing Values

missing pct
Employer Company 246 24.6
Dependants 19 1.9

Metrics by Retirement Status

Retired count mean_age mean_salary mean_pension
False 754 45.3 57431.9 0
True 246 81.8 58985.6 23883.8

Salary & Age by Marital Status

Marital Status count mean_salary median_salary mean_age
single 330 59446.2 59975.5 55.1
divorced 71 57865.6 58250 56
married or civil partner 541 57147.2 56477 54.1
widowed 58 54684.7 53060 50.1

Metrics by Sex

Sex count mean_salary median_salary mean_commute
Female 499 57721.3 57387 10.4
Male 501 57906.5 57690 10.5

Metrics by Dependants

Dependants count mean_salary mean_age
1 255 58096.8 54.7
2 479 57889 53.3
3 178 57927.8 54.4
4 54 55155.5 59.2
5 34 58264.8 57.8

Top 10 Employer Companies

Employer Company count
Evans Inc 3
Wright LLC 3
Smith PLC 3
Smith Ltd 3
Hawkins Group 2
Brown Ltd 2
Johnston PLC 2
Foster PLC 2
Williams PLC 2
Fletcher LLC 2

Correlation Matrix (numeric)

Age (Years) Yearly Salary (GBP) Yearly Pension (GBP) Distance Commuted to Work (miles) Dependants Vehicle Year
Age (Years) 1 0.05 0.69 -0.62 0.04 0.03
Yearly Salary (GBP) 0.05 1 0.03 0.42 -0.01 0.08
Yearly Pension (GBP) 0.69 0.03 1 -0.81 0 0.02
Distance Commuted to Work (miles) -0.62 0.42 -0.81 1 -0.01 0.01
Dependants 0.04 -0.01 0 -0.01 1 -0.05
Vehicle Year 0.03 0.08 0.02 0.01 -0.05 1

Visualizations

Distributions of Numeric Features

Numeric distributions

Correlation Heatmap

Correlation heatmap

Categorical Feature Counts

Categorical counts

Age vs Salary (by Retirement Status)

Age vs salary

Salary Distribution by Marital Status

Salary by marital status

Salary Distribution by Sex

Salary by sex

Commute Distance vs Salary

Commute vs salary

Age Distribution by Marital Status

Age by marital status

Salary by Number of Dependants

Salary by dependants

Vehicle Year Distribution

Vehicle year

Pairwise Relationships

Pairplot

Top 10 Employer Companies

Top employers

Key Findings

  • Pension income rises strongly with age (r ≈ 0.69), while salary is essentially flat across age.
  • Commute distance is strongly negatively correlated with pension (r ≈ -0.81) — retired customers no longer commute.
  • Retired customers (~25% of the sample) skew much older (mean age 82 vs 45) yet earn comparable salaries.
  • Salary shows no meaningful gap by sex, and only minor variation by marital status or dependants.

About

This project began as a university assignment and was later reworked into a standalone portfolio project. The dataset (acw_user_data.csv) is derived from publicly available open-government data.

License

Released under the MIT License.

About

Cleaning, restructuring, and exploratory analysis of 1,000 customer records — pure-Python preprocessing (CSV → nested JSON) plus a pandas/seaborn EDA with 12 figures and summary tables.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages