Phase 3 — Data Processing | Milestone 3
Load your raw data into pandas and produce the first cleaned version.
Topics:
- Read CSV/Excel/JSON into pandas
- DataFrame structure: rows, columns, dtypes, index
- Selecting columns and filtering rows
- Basic profiling:
head(),info(),describe(),value_counts() - Rename columns and standardize names
- Save processed outputs
Primary: Python for Data Science — cognitiveclass.ai
Optional: Python Official Getting Started Guide — review
Create scripts/transform.py or notebook cells that:
- Load the raw data
- Inspect and profile it
- Produce the first cleaned version in
/data/processed/
First cleaned dataset version committed to /data/processed/.
Estimated time: 5 hours
Start scripts/transform.py with a basic load-profile-save flow:
from pathlib import Path
import pandas as pd
RAW_FILE = Path("data/raw/<your_raw_file>.csv")
OUTPUT_FILE = Path("data/processed/<your_processed_file>.csv")
def main():
df = pd.read_csv(RAW_FILE)
print(df.head())
print(df.info())
df.columns = [col.strip().lower().replace(" ", "_") for col in df.columns]
OUTPUT_FILE.parent.mkdir(parents=True, exist_ok=True)
df.to_csv(OUTPUT_FILE, index=False)
print(f"Saved cleaned dataset to {OUTPUT_FILE}")
if __name__ == "__main__":
main()- Load the real raw file from
/data/raw. - Start with simple column cleanup and basic profiling before deeper cleaning.
- Save the first processed version even if it is not perfect yet.
scripts/transform.pyor equivalent notebook flow exists.- The raw file loads successfully.
- You inspected the structure with basic profiling.
- A first cleaned file is saved in
/data/processed.
- Jumping into complex cleaning before checking
info()andhead(). - Overwriting the raw file instead of writing to
/data/processed. - Renaming columns inconsistently.
- Treating the first cleaned version as the final version.
- Confirm the file path and file format first.
- Print the column names before writing any cleaning logic.
- Get one row-to-row save working before adding more transformations.