Inspecting Data: head, tail, info, describe
Inspecting data means using Pandas' built-in summary methods — head , tail , info , and describe — to get a fast, reliable overview of a dataset's contents, structure, and statistics before you analyse it.
Learn Inspecting Data: head, tail, info, describe in our free Pandas course — a beginner-friendly interactive lesson with worked examples, a practice…
Part of the free Pandas course at LearnCodingFast — hands-on lessons with examples you run in your browser, plus practice exercises and a quick quiz.
Never trust data you haven't looked at. These methods are the first thing every analyst runs on a fresh dataset.
What You'll Learn in This Lesson
1 Previewing Rows: head() and tail()
Real datasets can have thousands of rows. df.head() shows the first 5 and df.tail() shows the last 5 — a quick peek without flooding your screen:
2 Structure: info(), shape, columns, dtypes
df.info() prints a compact summary of the DataFrame's structure : how many rows, each column's name, its non-null count (great for spotting missing data), and its dtype.
- df.shape — (rows, columns)
- df.columns — the column names
- df.dtypes — the type of each column
3 Statistics: describe(), nunique(), value_counts()
df.describe() computes summary statistics for every numeric column — count, mean, standard deviation, min, the three quartiles, and max:
nunique() tells you how many distinct values a column has, while value_counts() tallies how many times each value appears — ideal for category columns.
📋 Quick Reference
Method
Tells You
df.head() / df.tail()
First / last rows
df.shape
(rows, columns)
df.info()
Types, non-null counts, memory
df.describe()
Numeric summary statistics
df.nunique()
Distinct values per column
df["col"].value_counts()
Tally of each value
🎯 Mini Challenge: Quick Audit
- Print the shape
- Preview the first 2 rows with head(2)
- Print describe() for the numbers
- Tally the team column with value_counts()
❓ Frequently Asked Questions
Lesson 6 complete — you can audit any dataset!
You can preview rows with head and tail, check structure and missing data with info, summarise numbers with describe, and tally categories with nunique and value_counts.
🚀 Up next: Selecting Columns and Rows — pick out exactly the data you need from any DataFrame.
Practice quiz
How many rows does df.head() show by default?
- 10
- 5
- 3
- All of them
Answer: 5. df.head() returns the first 5 rows by default.
What does df.tail(2) return?
- The first 2 rows
- Every other row
- The last 2 rows
- 2 random rows
Answer: The last 2 rows. tail(n) shows the last n rows; tail(2) shows the final two.
Which method summarises structure: column names, non-null counts, and dtypes?
- df.describe()
- df.head()
- df.value_counts()
- df.info()
Answer: df.info(). df.info() reports structure, non-null counts, dtypes, and memory usage.
Which method gives count, mean, std, min, quartiles, and max for numeric columns?
- df.describe()
- df.info()
- df.shape
- df.head()
Answer: df.describe(). df.describe() computes summary statistics for numeric columns.
What does df.shape return?
- The column names
- A tuple of (rows, columns)
- The dtypes
- The memory usage
Answer: A tuple of (rows, columns). df.shape is a (rows, columns) tuple.
What does df['col'].value_counts() do?
- Returns the column mean
- Sorts the column
- Tallies how many times each distinct value appears
- Counts the columns
Answer: Tallies how many times each distinct value appears. value_counts() counts occurrences of each value, sorted high to low.
What does df.nunique() report?
- The total row count
- The mean of each column
- The sum per column
- The number of distinct values per column
Answer: The number of distinct values per column. nunique() returns how many distinct values each column has.
What does df.info() return as its value?
- None (it prints the summary)
- A DataFrame
- A dictionary
- A list of dtypes
Answer: None (it prints the summary). info() prints its summary and returns None, so do not assign its result.
For scores [88, 72, 95, 60], what mean does describe() report?
- 78.75
- 80.0
- 72.0
- 95.0
Answer: 78.75. (88+72+95+60)/4 = 78.75.
What is the recommended first pair of methods to run on a new dataset?
- df.melt() and df.pivot()
- df.groupby() and df.agg()
- df.shape and df.head()
- df.drop() and df.fillna()
Answer: df.shape and df.head(). Start with df.shape and df.head() to see the size and a sample.