PY-401 ยท Analysis end to end
Exploratory analysis checklist
โฑ 9 min ๐ Real Python 3 ๐ฌ Animated โ Completed
โก 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.
import ioimport pandas as pdcsv_text = """order_id,region,units,price1,North,3,2.52,north,2,2.53,South,,3.04,East,5,2504,East,5,2505,South,4,3.0"""df = pd.read_csv(io.StringIO(csv_text))print(df.shape)print(df.isna().sum().to_dict())print("duplicates:", df.duplicated().sum())print(df["region"].value_counts().to_dict())print(df["price"].describe()[["min", "50%", "max"]].to_dict())
Change anything and press Run (or Ctrl+Enter). Then open Watch it and press Watch my code.
Input one line per input() call
Press Run to see the output. Python runs in your browser. Expected output
(6, 4)
{'order_id': 0, 'region': 0, 'units': 1, 'price': 0}
duplicates: 1
{'South': 2, 'East': 2, 'North': 1, 'north': 1}
{'min': 2.5, '50%': 3.0, 'max': 250.0} ๐ฏ Write first_look(df) that returns a dictionary with "rows" (row count), "missing" (total missing cells) and "duplicates" (number of duplicate rows).
Input one line per input() call
Press Run to see the output. Python runs in your browser. Need a hint?
return {"rows": len(df), "missing": int(df.isna().sum().sum()), "duplicates": int(df.duplicated().sum())}
- 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.
- The Python idea
df.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. - 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() 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.
Test yourself
5 questions. Get 4 right and this lesson is marked complete.
Pass the quiz to complete this lesson.
๐ Every lesson counts toward your certificate Next: Lab: Sales analysis โ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
- pandas.DataFrame.describe (docs.python.org)