🚀 LEVEL UP TO SENIOR:Unlock 500+ Advanced Practical Challenges & Exercises.
🎓 COURSERA PARTNER:Earn professional Google, Meta, and IBM certificates to supercharge your resume.
REFERENCEpandas

pandas Documentation

LOADING ENGINE...

df.describe()

AI & DATA SCIENCE // df-describe

df.describe() generates summary statistics for a DataFrame's numeric columns by default — count, mean, standard deviation, min, max, and quartiles — in one call.

Syntax

df.describe(include=None, percentiles=None)

Deep Dive Course

By default, describe() only summarizes numeric columns, silently skipping text/object columns entirely, since statistics like mean and standard deviation don't apply to them. Passing include='object', or include='all', expands the summary to include non-numeric columns too, which get a different set of statistics instead — count, number of unique values, the most frequent value, and its frequency — since numeric summary stats don't make sense for them.

1Understanding df.describe()

By default, describe() only summarizes numeric columns, silently skipping text/object columns entirely, since statistics like mean and standard deviation don't apply to them. Passing include='object', or include='all', expands the summary to include non-numeric columns too, which get a different set of statistics instead — count, number of unique values, the most frequent value, and its frequency — since numeric summary stats don't make sense for them.

💡

Pass include='all' to df.describe() to get a summary covering every column, both numeric and non-numeric, instead of describe()'s default of silently including only the numeric ones.

editor.html
import pandas as pd

df = pd.DataFrame({"age": [25, 30, 35, 40, 45]})
print(df.describe())
localhost:3000

2Practical Example

Here is a real-world application of df.describe() showing how it is used in production Pandas code.

editor.html
import pandas as pd

df = pd.DataFrame({"name": ["Alice", "Bob", "Alice"], "age": [30, 25, 35]})
print(df.describe(include="all"))
localhost:3000

3Best Practices

Follow these guidelines when working with df.describe():

1. Use describe() as a fast first look at a numeric dataset's overall distribution, before diving into more detailed analysis or visualization

2. Pass include='object' or include='all' explicitly when text/categorical columns also need summarizing, since the default silently excludes them

3. Compare describe()'s min/max/quartiles against expected real-world ranges to catch obviously invalid data, like a negative age, early

⚠️

Tip: Pass include='all' to df.describe() to get a summary covering every column, both numeric and non-numeric, instead of describe()'s default of silently including only the numeric ones.

editor.html
import pandas as pd

df = pd.DataFrame({"age": [25, 30, 35, 40, 45]})
print(df.describe())
localhost:3000

Examples

Example 01Basic Usage
import pandas as pd

df = pd.DataFrame({"age": [25, 30, 35, 40, 45]})
print(df.describe())
Example 02Advanced Example
import pandas as pd

df = pd.DataFrame({"name": ["Alice", "Bob", "Alice"], "age": [30, 25, 35]})
print(df.describe(include="all"))

Best Practices

  • Use describe() as a fast first look at a numeric dataset's overall distribution, before diving into more detailed analysis or visualization
  • Pass include='object' or include='all' explicitly when text/categorical columns also need summarizing, since the default silently excludes them
  • Compare describe()'s min/max/quartiles against expected real-world ranges to catch obviously invalid data, like a negative age, early

Interview Question

Why does df.describe() silently ignore text columns by default, and what statistics does it show for them instead if you explicitly include them?

Hint: Think about which statistics are actually meaningful for non-numeric data.

Statistics like mean, standard deviation, and quartiles are only mathematically meaningful for numeric data — there's no sensible average of a column of names, for instance — so describe()'s default behavior focuses only on the numeric columns where those calculations make sense, silently skipping the rest. Passing include='object' or include='all' brings text/categorical columns into the summary too, but with a different, appropriate set of statistics: the count of non-null values, the number of unique values, the most frequently occurring value, and how many times that top value appears.

Exercises

MediumPractice using df.describe() in a real scenario.
View Solution
import pandas as pd

df = pd.DataFrame({"age": [25, 30, 35, 40, 45]})
print(df.describe())

Frequently Asked Questions

Why does df.describe() silently ignore text columns by default, and what statistics does it show for them instead if you explicitly include them?

Statistics like mean, standard deviation, and quartiles are only mathematically meaningful for numeric data — there's no sensible average of a column of names, for instance — so describe()'s default behavior focuses only on the numeric columns where those calculations make sense, silently skipping the rest. Passing include='object' or include='all' brings text/categorical columns into the summary too, but with a different, appropriate set of statistics: the count of non-null values, the number of unique values, the most frequently occurring value, and how many times that top value appears.

Related Functions

df-infodf-dtypesdf-mean