Skip to content

Beginner: data foundations · Cleaning, exploring and visualising data · topic 20 of 62 · 30 min

Exploratory data analysis (EDA)

Explanation

Exploratory data analysis means getting to know a dataset before you model it: its size, types, missing values, distributions, outliers and relationships. You ask questions, look at numbers and charts, and write down what you find. Good EDA prevents most later mistakes.

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

  1. Size and grain: how many rows and columns, and what is one row? (One order? One customer per day?)
  2. Types: which columns are numbers, categories, dates, free text, ids?
  3. Missing values: how many per column, and is the missingness random or meaningful?
  4. Univariate look: for each important column, its distribution. Numbers: min, max, mean, median, histogram. Categories: counts.
  5. Outliers and impossible values: negative quantities, ages of 200, dates in the future.
  6. Bivariate look: how pairs of columns relate, such as delivery time vs distance (scatter), or cancellation rate by city (grouped bar).
  7. The target: if you will predict something, how is it distributed? Is it rare (2% fraud)?
  8. 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.

python
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()
A typical first EDA pass in pandas (shown only). Each line answers one question from the checklist.

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.

Think of it like this: EDA is like a new shopkeeper's first week in a shop. Before changing anything, she walks the aisles, counts what is on each shelf, notices which items are dusty and which are always empty, and asks the old staff why. Only then does she decide what to change.

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

EDA

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)

Task 1 · Code · Python

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.

Task 2 · Code · Python

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.

Task 3 · Practice

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

Question 1

1.What is the "grain" of a dataset?

Question 2

2.Which is a bivariate check?

Question 3

3.Why look at distributions and not just averages?

Question 4

4.While exploring, you slice the data 50 ways and find one surprising pattern. What should you do?

Read more (free)

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.

From Visualising data honestly

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.

From What data science is, and how this course works

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.

From Designing the data model

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.

From Correlation: how two things move together

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. 1 more topic in “Cleaning, exploring and visualising data” before its exam: Visualising data honestly.
  2. Module 4 exam: Cleaning, exploring and visualising data · 12 questions · 25 min, without help. 6 topics of this module still to finish first.
  3. Then the next module, The ML workflow, regression and classification. 62 topics left in the course before the final exam.

← Previous: Grouping, joining and reshaping