The describe() function quickly shows important summary numbers about your data. It helps you understand your data's main features without looking at every value.
You want to see the average, minimum, and maximum of a dataset fast.
You need to check how spread out your data values are.
You want to find out how many data points you have and if there are missing values.
You want a quick overview before making graphs or deeper analysis.
You can choose which columns or data types to include or exclude.
Examples
Shows summary statistics for all numeric columns in the DataFrame df.
Data Analysis Python
df.describe()
Shows summary statistics for the single column age.
Data Analysis Python
df['age'].describe()
Shows summary statistics for all columns, including non-numeric ones.
Data Analysis Python
df.describe(include='all')
Sample Program
This code creates a small table of ages, heights, and weights. Then it uses describe() to get count, mean, std (spread), min, max, and quartiles for each column.
Data Analysis Python
import pandas as pd
# Create a simple DataFrame
data = {'age': [25, 30, 22, 40, 28],
'height': [175, 180, 168, 190, 172],
'weight': [70, 80, 60, 90, 65]}
df = pd.DataFrame(data)
# Use describe() to get summary statistics
summary = df.describe()
print(summary)
OutputSuccess
Important Notes
describe() ignores missing values by default.
For non-numeric data, describe() shows count, unique values, top (most common), and frequency.
Summary
describe() quickly summarizes your data's main statistics.
It works on numeric and non-numeric data with different outputs.
Use it first to understand your data before deeper analysis.
Practice
(1/5)
1. What does the describe() function in pandas primarily provide for a DataFrame?
easy
A. A sorted version of the DataFrame
B. A plot of the data distribution
C. A list of all column names
D. A summary of main statistics like mean, median, and count
Solution
Step 1: Understand the purpose of describe()
The describe() function summarizes key statistics such as count, mean, std, min, max, and quartiles for numeric data.
Step 2: Compare with other options
Options B, C, and D describe different functions or outputs unrelated to describe().
Final Answer:
A summary of main statistics like mean, median, and count -> Option D
2. Which of the following is the correct way to call describe() on a pandas DataFrame named df?
easy
A. df.describe()
B. describe(df)
C. df.describe
D. df.describe[]
Solution
Step 1: Recall pandas method syntax
Methods are called with parentheses after the method name, so df.describe() is correct.
Step 2: Check other options for syntax errors
df.describe[] uses invalid square brackets; describe(df) incorrectly calls it as a standalone function; df.describe misses parentheses and prints the method object.
Final Answer:
df.describe() -> Option A
Quick Check:
Method call needs () = df.describe() [OK]
Hint: Call methods with parentheses: df.describe() [OK]
B. describe is not a pandas function; import missing
C. Missing parentheses after describe; fix with df.describe()
D. Syntax error in DataFrame creation
Solution
Step 1: Identify the problem
The code references df.describe without parentheses, so it prints the method object, not the result.
Step 2: Fix the code
Add parentheses to call the method: df.describe().
Final Answer:
Missing parentheses after describe; fix with df.describe() -> Option C
Quick Check:
Method call needs () = df.describe() [OK]
Hint: Always use () to call methods [OK]
Common Mistakes:
Forgetting parentheses on method calls
Assuming describe is not a method
Thinking DataFrame needs more columns
5. You have a DataFrame df with numeric and categorical columns. You want describe() to include statistics for all columns, not just numeric ones. Which code will achieve this?
hard
A. df.describe(exclude='all')
B. df.describe(include='all')
C. df.describe(numeric_only=True)
D. df.describe(include='numeric')
Solution
Step 1: Understand describe() default behavior
By default, describe() shows stats only for numeric columns.
Step 2: Use include='all' to get all columns
Passing include='all' makes describe() summarize numeric and categorical columns.
Step 3: Check other options
exclude='all' excludes all columns (invalid result); numeric_only=True limits to numeric only; include='numeric' matches default.
Final Answer:
df.describe(include='all') -> Option B
Quick Check:
include='all' = all columns summary [OK]
Hint: Use include='all' to describe all columns [OK]
Common Mistakes:
Using numeric_only=True to get all columns
Confusing include and exclude parameters
Passing invalid values to include
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.