Beginner: data foundations · Cleaning, exploring and visualising data · topic 20 of 62 · 30 min
Exploratory data analysis (EDA)
Explanation
Why explore first?
Jumping straight to a model is like a doctor prescribing medicine without examining the patient. EDA is the examination. It tells you whether the data can answer your question at all, which columns are useful, what needs cleaning, and what patterns a model should find. Many projects are saved, or quietly cancelled, during EDA.
An EDA checklist
- Size and grain: how many rows and columns, and what is one row? (One order? One customer per day?)
- Types: which columns are numbers, categories, dates, free text, ids?
- Missing values: how many per column, and is the missingness random or meaningful?
- Univariate look: for each important column, its distribution. Numbers: min, max, mean, median, histogram. Categories: counts.
- Outliers and impossible values: negative quantities, ages of 200, dates in the future.
- Bivariate look: how pairs of columns relate, such as delivery time vs distance (scatter), or cancellation rate by city (grouped bar).
- The target: if you will predict something, how is it distributed? Is it rare (2% fraud)?
- Write findings and questions down as you go.
Univariate and bivariate
Univariate means one variable at a time. Bivariate means two together. A histogram of delivery times is univariate. A scatter plot of delivery time against distance is bivariate. Correlation numbers (from module 2) summarise linear bivariate relationships, but always look at the chart too: a correlation near 0 can hide a strong curved pattern.
df.shape # (48210, 9)
df.isna().mean().round(3) # share missing per column
df["delivery_min"].describe()
df["city"].value_counts().head(10)
df.groupby("city")["delivery_min"].median().sort_values()
df[["distance_km", "delivery_min"]].corr()Ask questions, then check them
Good EDA is driven by questions. "Are weekend orders slower?" "Do new restaurants get more cancellations?" Write the question, compute the answer, then note it. Each answer usually raises a new question. Be careful: with enough slicing, something will always look interesting by chance, so treat surprising patterns as ideas to test, not facts.
Common mistakes
- Skipping EDA because "the model will figure it out". Fix: spend real time here; it pays back.
- Looking only at averages. Fix: always look at distributions; two very different datasets can share a mean.
- Not knowing what one row means, then counting customers when the rows are orders. Fix: state the grain first.
- Exploring the test data too and tuning decisions to it. Fix: once you split for modelling, explore only the training part.
- Forgetting to write findings down. Fix: keep a short "what I found" list at the top of the notebook.
Need help?
Stuck on a word or an idea? Search this course, or every course, and jump straight to the explanation or a worked question.
Try:
Watch the lesson
Exploratory data analysis (EDA) · 1/6
Exploratory data analysis is getting to know your data before you model it.
Prefer a video by a teacher? Find free videos on “exploratory data analysis python pandas step by step” on YouTube ↗
In real life: EDA before predicting late deliveries
Before building a model for late food deliveries, an analyst explores three months of orders. She finds that 4% of rows have a missing distance, that late deliveries jump sharply during heavy rain, that one city logs time in a different time zone format, and that "late" is defined differently in two teams' reports. Fixing these four issues mattered more for the final model than any choice of algorithm.
Practice (0/3 done)
Write column_summary(rows, column) where rows is a list of dicts and missing values are None. Return a dict with "count" (non-missing values), "missing" (number of None values), "min", "max" and "mean" (rounded to 2) of the non-missing values. If all values are missing, min, max and mean are None.
Write impossible_rows(rows) for delivery data. Each row is a dict with "id", "minutes" and "distance_km". Return the list of ids (in order) where the data is impossible: minutes is 0 or less, OR distance_km is negative, OR minutes is more than 600.
Pick a public dataset you like (for example from data.gov.in or Kaggle) and write a one-page EDA note: what one row means, the column types, missing values, two interesting distributions, one relationship between two columns, and three questions you would investigate next.
Quick quiz
Read more (free)
Related help
Before this, learn
This topic builds on these. If something here feels new, open them first.
Related topics
Questions people ask about this
Open a question to see the answer and why. The first ones are this topic's own quiz, so try the quiz above before you peek.
What is the "grain" of a dataset?
Answer: What one row represents
Knowing the grain stops you from counting the wrong thing.
Which is a bivariate check?
Answer: A scatter plot of distance vs delivery time
Bivariate means looking at two variables together.
Why look at distributions and not just averages?
Answer: Very different data can have the same average; the shape shows skew, gaps and outliers
Two datasets can share a mean while one is tight and the other is wild.
While exploring, you slice the data 50 ways and find one surprising pattern. What should you do?
Answer: Treat it as an idea to test properly, since slicing many ways finds chance patterns
Many slices make chance findings likely. Confirm with fresh data or a proper test.
You want to see how delivery times are spread. Which chart?Related
Answer: Histogram
A histogram shows the distribution of one numeric variable.
Who usually puts a trained model into a live product and keeps it running?Related
Answer: An ML engineer
ML engineers focus on deploying, scaling and monitoring models in real products.
In the Notes app, why is user_id stored in the notes table?Related
Answer: It is a foreign key that says which user owns the note
One user has many notes, so each note row records its owner with a foreign key pointing to users.id.
A scatter plot shows a perfect U shape, but r is close to 0. What is true?Related
Answer: r only measures straight-line relationships, so it misses the curve
r measures linear association; a strong curved pattern can still give r near 0.
Pass the quiz (60% or more) or mark this topic as done when you are ready.
Your progress is saved on this device only.
Next steps
- 1 more topic in “Cleaning, exploring and visualising data” before its exam: Visualising data honestly.
- Module 4 exam: Cleaning, exploring and visualising data · 12 questions · 25 min, without help. 6 topics of this module still to finish first.
- Then the next module, The ML workflow, regression and classification. 62 topics left in the course before the final exam.