Exploratory Data Analysis (EDA) — A Real Methodology

Data Science Fundamentals

Chapter 9 · Exploratory Data Analysis (EDA) — A Real Methodology

ds1-3 through ds1-8 built a toolkit — reading data, cleaning it, combining it, describing it, plotting it — one technique at a time, on one running coffee-shop dataset. This chapter formally names the method those tools were all building toward, and deliberately applies it to a fresh dataset the coffee-shop material never touched: a small used-car listings table. The method, not a memorized sequence of steps on one specific dataset, is what this chapter needs to transfer — which is exactly why ds1-10's own capstone will apply this same seven-step structure to a third, still-different dataset.

makemodelyearmileagepricefuel_type
ToyotaCorolla201942,00016,500Petrol
HondaCivic202028,50018,200Petrol
TeslaModel 3202119,00031,800Electric
FordFocus201588,0007,200Diesel
ToyotaCorolla20229,50021,900Petrol
FordFocus201676,0007,800Diesel
JaguarE-Type196861,00085,000Petrol

The Seven-Step Methodology

  • Understand the shape. df.shape, df.info(), df.head()ds1-3's own first tools. How many rows and columns, what types, any obviously missing values.
  • Summary statistics. df.describe() — every one of ds1-6's own vocabulary terms (mean, std, Q1, median, Q3) for every numeric column, in one call.
  • Univariate analysis — one variable at a time. A histogram (ds1-7) of price; df["fuel_type"].value_counts() for a categorical breakdown.
  • Bivariate analysis — two variables at a time. A scatter plot (ds1-7) of mileage vs. price; a box plot (ds1-8) of price grouped by fuel_type.
  • Multivariate analysis — three or more variables at once. A correlation heatmap and a pair plot (ds1-8) across every numeric column simultaneously.
  • Spot anomalies. ds1-4's own IQR rule and ds1-8's own box plot, applied here.
  • Form hypotheses. The actual point of everything above — turning patterns into specific, testable questions.
  • Steps 3–5, Worked

    df["price"].plot(kind="hist")                          # univariate — ds1-7's histogram
    df["fuel_type"].value_counts()                          # univariate — categorical breakdown
    
    df.plot(kind="scatter", x="mileage", y="price")          # bivariate — ds1-7's scatter plot
    sns.boxplot(data=df, x="fuel_type", y="price")           # bivariate — ds1-8's box plot, grouped
    
    sns.heatmap(df[["year","mileage","price"]].corr(), annot=True)   # multivariate — ds1-8's heatmap
    sns.pairplot(df[["year","mileage","price"]])                     # multivariate — ds1-8's pair plot

    The mileage-vs-price scatter plot here shows something the coffee-shop dataset's own quantity-vs-revenue scatter (ds1-7) never did: a clear negative correlation — higher mileage, lower price. Same tool, same underlying Pearson mechanism (ds1-6), a genuinely different real-world relationship.

    Step 6: Spotting Anomalies, Honestly

    Running ds1-4's own IQR rule on price flags the 1968 Jaguar E-Type immediately — its price sits far above every other listing. Exactly the honest distinction ds1-4 and ds1-6 already insisted on: this isn't a data-entry error to delete. A genuine vintage collector's car legitimately commands a price with no relationship at all to the mileage/age/price pattern the rest of the dataset follows — flagging it is correct; discarding it would be a real mistake, and would also quietly remove the row most worth asking a follow-up question about.

    Step 7: Forming Hypotheses — The Actual Point of EDA

    Everything above describes what the data is. This step turns that description into specific, testable questions:

    • "Does mileage predict price more strongly than the car's year does?" — a question the heatmap's own two separate correlation values already give a first, rough answer to.
    • "Is the Jaguar a genuinely different category of listing (collectible) that should be modeled separately from ordinary used cars?"
    • "Does fuel type meaningfully shift price once mileage and year are accounted for?"
    EDA identifies what's worth modeling — it doesn't build the model
    None of these questions get answered by anything in this chapter. EDA's own job ends at forming a specific, well-motivated question backed by a real pattern already seen in the data — actually building something that predicts price from mileage and year is ml1's entire job, start to finish. This chapter's own seven steps are the bridge that decides what's worth building in the first place, not the construction itself.

    Hands-On Exercises

    Exercise 1

    Explain, using this chapter's own seven-step list, which step each of the following belongs to: df.describe(), a box plot of price grouped by fuel_type, and a correlation heatmap across year/mileage/price.

    📄 View solution
    Exercise 2

    Explain why the mileage-vs-price scatter plot in this chapter shows a negative correlation while ds1-7's own quantity-vs-revenue scatter plot showed a positive one, and explain why this doesn't mean one chapter's own correlation mechanism is different from the other's.

    📄 View solution
    Exercise 3

    Using this chapter's own warn-box, explain the difference between what Step 7 (forming hypotheses) actually accomplishes and what ml1 accomplishes, and explain why "does mileage predict price?" is a hypothesis this chapter raises but doesn't answer.

    📄 View solution

    Chapter 9 Quick Reference — The Seven-Step EDA Methodology

    • 1. Shape (ds1-3) → 2. Summary stats (ds1-6) → 3. Univariate (ds1-7) → 4. Bivariate (ds1-7/ds1-8) → 5. Multivariate (ds1-8) → 6. Anomalies (ds1-4/ds1-8) → 7. Hypotheses
    • Applied here to a fresh used-car dataset — a genuinely different domain from ds1-3–ds1-8's own coffee-shop table, on purpose
    • An outlier flagged in Step 6 (the Jaguar) may be the single most interesting row, not an error to delete
    • Step 7 forms testable questions — it deliberately does not answer them; that's ml1's own job
    • Next chapter: Capstone: A Full EDA Project on a Real Dataset