ETL pipeline that processes e-commerce data to generate sales metrics. Built in Python using pandas, with a focus on data cleaning, normalization, and proper data typing.
The pipeline is designed to run in isolated environments (Docker or virtual environment).
- Python
- pandas
- numpy
- pyarrow
- Docker
The project works with multiple CSV files that make up an e-commerce system (orders, customers, products, etc.). The input files follow a predefined schema (file and field names) expected by the pipeline.
src/
├─ extract.py
├─ transform.py
├─ load.py
├─ analytics.py
├─ main.py
├─ __init__.py
└─ config.py
.venv/
data/ # inputs (non-versioned)
output/ # results (non-versioned)
dockerfile
.dockerignore
.gitignore
README.md
requirements.txt
src/: pipeline code (extract, transform, load, analytics, main, init)data/: input data (non-versioned)output/: results (non-versioned)config.py: path configuration and output formats
Extract → Transform → Analytics → Load
Create a virtual environment and install dependencies:
python -m venv .venv
.venv\Scripts\Activate
pip install -r requirements.txtExecute pipeline:
python -m src.mainThe ETL process expects CSV files in the data/ directory and will write the results to output/.
docker build -t etl-project.
docker run --rm -v "%cd%\data":/app/data -v "%cd%\output":/app/output etl-project- Reading CSV files
- Load validation
- Normalization of nulls
- Cleaning of empty strings
- Data type conversion considering primary and foreign keys to maintain relational consistency
- Date conversion
- Optional conversion of Period → timestamp for compatibility with BI tools and Parquet
- DF_ORDERS: Replacing nulls in
noteswith “No notes,” since it is an optional field. - DF_ORDERS: Retaining nulls in
promotion_idbecause they represent the absence of a relationship (FK). - DF_CATEGORIES:
parent_category_idretains nulls since they identify parent categories.
As a test, duplicates were evaluated excluding PK. It was verified that duplicates in order_items correspond to multiple products within the same order.
Reusable functions were created:
cast_columnscast_to_date
The conversions take into account data functionality, future loads, and analysis.
Results are saved in CSV and/or Parquet format depending on the configuration in src/config.py.
Examples:
- top_clients
- most_sold_product
- monthly_sales
The pipeline enables reproducible export for analytical and BI use.
- Centralized configuration
- Configurable export
- Supports local execution and Docker
- Inputs and outputs decoupled from the repository for reproducibility
- More robust error handling
Gaston Rodriguez