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.
| make | model | year | mileage | price | fuel_type |
|---|---|---|---|---|---|
| Toyota | Corolla | 2019 | 42,000 | 16,500 | Petrol |
| Honda | Civic | 2020 | 28,500 | 18,200 | Petrol |
| Tesla | Model 3 | 2021 | 19,000 | 31,800 | Electric |
| Ford | Focus | 2015 | 88,000 | 7,200 | Diesel |
| Toyota | Corolla | 2022 | 9,500 | 21,900 | Petrol |
| Ford | Focus | 2016 | 76,000 | 7,800 | Diesel |
| Jaguar | E-Type | 1968 | 61,000 | 85,000 | Petrol |
The Seven-Step Methodology
df.shape, df.info(), df.head() — ds1-3's own first tools. How many rows and columns, what types, any obviously missing values.df.describe() — every one of ds1-6's own vocabulary terms (mean, std, Q1, median, Q3) for every numeric column, in one call.ds1-7) of price; df["fuel_type"].value_counts() for a categorical breakdown.ds1-7) of mileage vs. price; a box plot (ds1-8) of price grouped by fuel_type.ds1-8) across every numeric column simultaneously.ds1-4's own IQR rule and ds1-8's own box plot, applied here.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?"
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
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 solutionExplain 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 solutionUsing 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 solutionChapter 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