A practical implementation of fundamental data cleaning and preprocessing techniques in Python using Pandas. This repository covers missing data imputation, duplicate record elimination, and feature scaling via Min-Max normalization.
In machine learning and statistical data analysis, raw datasets are rarely clean. They often contain missing entries, redundant records, and unscaled numerical features. This project demonstrates how to address these common issues systematically.
-
Handling Missing Values (Imputation): Filling numerical missing values with the column mean and categorical null values with a constant placeholder (
'Unknown'). - Deduplication: Detecting and dropping redundant rows to prevent data leakage and bias.
-
Feature Scaling (Min-Max Normalization): Transforming numerical features into a standard range
$[0, 1]$ to ensure uniform weight distribution across machine learning algorithms.
Min-Max Scaling shifts and rescales values so that they bound strictly within
Where:
-
$x$ is the original feature value. -
$x_{\min}$ is the minimum value in the feature column. -
$x_{\max}$ is the maximum value in the feature column. -
$x_{\text{norm}}$ is the rescaled value between$0.0$ and$1.0$ .
(Included in the modular pipeline)
Where:
-
$\mu$ is the column mean. -
$\sigma$ is the column standard deviation.
pandas-data-preprocessing/
├── data/
│ ├── students_data.csv # Sample dataset with duplicates and missing values
│ └── students_cleaned.csv # Cleaned and normalized output dataset
├── data_preprocessing.py # Direct assignment script with formatted output
├── data_preprocessing_pipeline.py # Production-ready modular preprocessing class
├── data_preprocessing.ipynb # Interactive Jupyter Notebook walkthrough
├── requirements.txt # Dependencies
├── .gitignore # Git ignore file for Python & Notebooks
└── README.md # Project documentation
Ensure you have Python 3.9+ installed on your system.
Clone the repository and install the dependencies:
git clone https://github.com/ombichave999/pandas-data-preprocessing.git
cd pandas-data-preprocessing
pip install -r requirements.txtExecutes the step-by-step cleaning on the sample DataFrame:
python data_preprocessing.pyLoads raw CSV data, executes the preprocessing pipeline, and exports the clean dataset:
python data_preprocessing_pipeline.pyFor interactive experimentation or academic presentations:
jupyter notebook data_preprocessing.ipynb| Name | Age | Marks | Issue |
|---|---|---|---|
| Amit | 22.0 | 85.0 | Valid |
| Riya | 24.0 | 90.0 | Valid |
| Amit | 22.0 | 85.0 | Duplicate |
| Neha | NaN | 78.0 | Missing Age |
| NaN | 26.0 | NaN | Missing Name & Marks |
==================================================
Final Processed Data
==================================================
Name Age Marks Age_Normalized Marks_Normalized
Amit 22.0 85.0 0.000 0.583333
Riya 24.0 90.0 0.500 1.000000
Neha 23.5 78.0 0.375 0.000000
Unknown 26.0 84.5 1.000 0.541667
Tip
Deduplication Before Imputation: When calculating statistical properties (e.g. mean, median) for imputation, duplicate entries artificially skew the calculations. In production pipelines, deduplicate the data first so that summary statistics accurately represent the underlying distribution.
MIT License. Free to use for educational and research purposes.