Sub topic 1
Start with Questions, Not Code
Prerequisites
Assume you can write basic Python functions, import packages, and work with pandas DataFrames in Jupyter. You should know mean, median, distributions, and correlation.
Start with Questions, Not Code
Exploratory data analysis (EDA) is an investigation of a dataset before formal modeling. Begin by writing questions that can guide the investigation:
- Which regions have the most orders?
- Is order amount strongly skewed?
- Which columns have missing or impossible values?
- Do large orders cluster by region or date?
Each question should name the data needed and the comparison you will make. This prevents a notebook from becoming a collection of unrelated plots.
A Section Layout That Tells a Story
Use sections that move from context to evidence:
- Questions and goals
- Reproducible setup
- Data loading
- First look
- Data-quality audit
- Cleaning
- Univariate and bivariate exploration
- Findings, limitations, and handoff
The order matters. A reader should understand what you checked, why you checked it, and what the evidence suggests.
The Setup Cell: Imports, Paths, and Seeds
Keep configuration near the top. A fixed random seed makes random sampling or demonstrations repeatable. A Path object makes the data location explicit.
from pathlib import Path
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
SEED = 42
rng = np.random.default_rng(SEED)
RAW_PATH = Path("data/raw/orders.csv")
pd.set_option("display.max_columns", 50)Loading Data and Leaving the Raw Copy Alone
Load the source into a clearly named variable. Do not clean it in place. Keeping df_raw unchanged lets you compare results with the original and rerun cleaning rules safely.
df_raw = pd.read_csv(RAW_PATH, parse_dates=["order_date"])A First Look at Shape, Types, and Summaries
Inspect size, column types, and broad statistics before plotting. These checks reveal unexpected types, empty columns, and unusual ranges.
print(df_raw.shape)
df_raw.info()
print(df_raw.describe(include="all").T)Exercise
Why should the raw DataFrame remain unchanged?
Show answer
It preserves a reference copy, makes cleaning reproducible, and helps detect changes introduced by later steps.