Lesson 22 of 23
โฎPrev Nextโฏ

PY-401 ยท Analysis end to end

Exploratory analysis checklist

โฑ 9 min ๐Ÿ Real Python 3 ๐ŸŽฌ Animated

22of 23

Your note

My notes for this lesson

Select any text in the lesson to highlight it or add a note. Saved in this browser.

    No highlights yet. Select a sentence in the lesson, then pick a colour or add a note.

    All my bookmarks and notes

    Reading settings

    For every lesson, saved in this browser.

    Text size
    Line spacing
    Font

    With IaaS you rent the virtual machine. Microsoft looks after the building, power and hardware; you patch the operating system.

    โšก The 30-second answer

    Exploratory data analysis (EDA) is the first look at a new dataset to learn what it holds and what is wrong with it before you trust any answer. A repeatable checklist covers size (shape), types (dtypes), gaps (isna().sum()), repeats (duplicated().sum()), ranges (describe()) and categories (value_counts()). Only then do you start answering the business question.

    • Run the same first checks on every dataset
    • Read describe() and value_counts()
    • Turn findings into cleaning steps

    Try it

    Watch it come alive, run it yourself, then prove it. Real Python, right on this page.

    Watch Python run the example. Every variable is a jar; watch the values change and the output appear.

    Exploratory analysis checklist, running
    1. import io
    2. import pandas as pd
    3. csv_text = """order_id,region,units,price
    4. 1,North,3,2.5
    5. 2,north,2,2.5
    6. 3,South,,3.0
    7. 4,East,5,250
    8. 4,East,5,250
    9. 5,South,4,3.0
    10. """
    11. df = pd.read_csv(io.StringIO(csv_text))
    12. print(df.shape)
    13. print(df.isna().sum().to_dict())
    14. print("duplicates:", df.duplicated().sum())
    15. print(df["region"].value_counts().to_dict())
    16. print(df["price"].describe()[["min", "50%", "max"]].to_dict())
    Press โ–ถ to watch Python run this, one line at a time.
    1. The problemAn analyst reported that the average order was 4,000. It was 40. One row had a price typed in pence instead of pounds. Five minutes of checks would have caught it.
    2. The Python ideadf.shape; df.dtypesExploratory data analysis (EDA) is the first look at a new dataset to learn what it holds and what is wrong with it before you trust any answer.
    3. In real lifeA bank's data team runs the same EDA notebook on every new data feed before it reaches the risk models. It once caught a feed where every amount was suddenly 100 times larger: a change from pounds to pence.

    Start with a question

    An analyst reported that the average order was 4,000. It was 40. One row had a price typed in pence instead of pounds. Five minutes of checks would have caught it.

    Every wrong result in data work traces back to data nobody looked at. EDA is cheap, and it protects every chart and number that comes after.

    Explain it like I'm 10

    Before you cook, you check the fridge: what is there, what has gone off, what is missing. EDA is checking the data fridge before you start cooking the answer.

    The technical explanation

    Size and types: df.shape and df.dtypes. Numbers stored as text and dates stored as text show up here.

    Gaps and repeats: df.isna().sum() and df.duplicated().sum(). Each one becomes a cleaning step from module 3.

    Ranges: df.describe() gives count, mean, min, max and quartiles per number column. A min of -5 units or a max 100 times the median is a red flag.

    Categories: df["region"].value_counts() shows each category and how often it appears, which reveals typos like "north" and "North".

    Syntax

    df.shape; df.dtypes
    df.isna().sum(); df.duplicated().sum()
    df.describe()
    df["col"].value_counts()

    โ–ถ Run the example ๐ŸŽฌ Watch it come alive

    Real-world scenario

    A bank's data team runs the same EDA notebook on every new data feed before it reaches the risk models. It once caught a feed where every amount was suddenly 100 times larger: a change from pounds to pence.

    Ready for more?The full lesson adds the technical explanation, interview questions and quick revision.

    Test yourself

    5 questions. Get 4 right and this lesson is marked complete.

    1. 1. What is exploratory data analysis for?
    2. 2. Which shows min, max and mean of number columns?
    3. 3. value_counts shows "North": 40 and "north": 3. What does that reveal?
    4. 4. The max price is 100 times the median. What do you do?
    5. 5. Why wrap your checks in a function?

    Questions people ask

    What are the first steps of exploratory data analysis in Python?

    Load the data, then check shape, dtypes, missing values with isna().sum(), duplicates with duplicated().sum(), number ranges with describe() and categories with value_counts(). Fix what you find before analysing.

    What is the difference between df.info() and df.describe()?

    info lists every column with its type and count of non-missing values. describe gives statistics such as mean, min, max and quartiles for the number columns.

    Interview questions

    How this topic comes up in Python interviews. Answer out loud first, then open the model answer.

    beginner What are the first steps of exploratory data analysis in Python?

    Load the data, then check shape, dtypes, missing values with isna().sum(), duplicates with duplicated().sum(), number ranges with describe() and categories with value_counts(). Fix what you find before analysing.

    beginner What is the difference between df.info() and df.describe()?

    info lists every column with its type and count of non-missing values. describe gives statistics such as mean, min, max and quartiles for the number columns.

    intermediate What is exploratory data analysis for?

    Learning what the data holds and what is wrong before trusting answers. EDA comes first and protects every later step.

    intermediate Which shows min, max and mean of number columns?

    df.describe(). describe summarises numeric columns.

    Quick revision

    Remember

    • Run the same first checks on every dataset
    • Read describe() and value_counts()
    • Turn findings into cleaning steps
    • Write your checks as a function, def first_look(df):, and run it on every new file. A checklist you do not have to remember is a checklist you actually run.

    Syntax

    df.shape; df.dtypes
    df.isna().sum(); df.duplicated().sum()
    df.describe()
    df["col"].value_counts()

    Official documentation