šŸš€ LEVEL UP TO SENIOR:Unlock 500+ Advanced Practical Challenges & Exercises.
šŸŽ“ COURSERA PARTNER:Earn professional Google, Meta, and IBM certificates to supercharge your resume.
HTML MASTER CLASS /// LEARN TAGS /// BUILD STRUCTURE /// SEMANTIC WEB /// HTML MASTER CLASS /// LEARN TAGS ///

Descriptive Data Analysis in Python

Learn about Descriptive Data Analysis in this comprehensive Python tutorial. Master the core Pandas methods used to structurally summarize numerical and categorical data instantly.

⚔ Total XP: 0|šŸ’» pandas XP: 0

Skill Matrix

UNLOCK NODES BY LEARNING NEW TAGS.

System Hub

Core logic.

Quick Quiz //

Why call df['Revenue'].mean() instead of df.describe() when you only need the average?


šŸš€ LEVEL UP TO SENIOR:Unlock 500+ Advanced Practical Challenges & Exercises.
šŸŽ“ COURSERA PARTNER:Earn professional Google, Meta, and IBM certificates to supercharge your resume.

Listen up. If you're going to process data in Python, you need to understand Descriptive Data Analysis in Python. This is where data engineers separate themselves from script kiddies. It's about writing code that scales.

1Pandas data analysis Part 1

Before you can draw conclusions from a dataset, you need to understand its statistical shape: what's the typical value, how spread out is the data, and are there outliers skewing things? Pandas' describe() method gives you that entire picture in one call — count, mean, standard deviation, min, max, and the 25th/50th/75th percentiles for every numeric column.

When you need a single specific number rather than the full summary, Pandas exposes the individual statistics directly: .mean() for the arithmetic average, .median() for the middle value once the data is sorted, and .mode() for the most frequently occurring value. Median is especially useful on skewed data — a handful of extreme outliers (like a few huge transactions) can drag the mean far from what's 'typical', while the median stays anchored to the center of the distribution.

Numeric statistics don't make sense for text columns, so Pandas offers a parallel toolkit for categorical data. value_counts() tallies how many times each distinct value appears in a column (e.g. how many rows belong to each state), while nunique() answers a narrower question — not how often each value shows up, but simply how many distinct values exist in the column at all.

āœ•
—
+
# Example
import pandas as pd
print("Running Pandas...")
localhost:3000
Jupyter Notebook / Console Output
Code Executed Successfully
Data processed and aggregated.

2Step-by-Step Breakdown

When you first load a dataset, you need to understand its statistical shape. The most powerful command for this is describe().

Which Pandas method generates a summary of statistics (count, mean, min, max, quartiles) for all numerical columns?

  • →summary()
  • →describe()
  • →stats()

You can also extract specific metrics manually. Use .mean() for the average, .median() for the middle value, and .mode() for the most frequent value.

If you want to find the exact middle value of a dataset, ignoring massive extreme outliers, which method should you use?

  • →mean()
  • →mode()
  • →median()

For categorical data (like text), math doesn't work. Instead, we use value_counts() to see how many times each distinct value appears.

Which method should you use on a text column to get a frequency count of every unique category?

  • →count_all()
  • →value_counts()
  • →sum()

Now, prepare yourself. We are about to enter the ADA Defense Protocol. Ensure you know how to find the uniqueness of a dataset.

ADA DEFENSE: You don't want to count the occurrences; you just want to know how many DIFFERENT (unique) states exist in the column. Which method returns the number of unique elements?

  • →unique_count()
  • →nunique()
  • →distinct()

Threat neutralized. Descriptive profiling complete. You have a full mathematical understanding of the data.

Threat neutralized. Concept validated. Proceed to the next section.

Find a Real Median, Ignoring Outliers. Finish middle_value(): use median() so the extreme outlier doesn't skew the result the way mean() would.

Level Up šŸš€

Advanced cheat sheets, SEO tricks, and interview prep for this topic.

Browser Support

ChromeSupported

Fully supported.

FirefoxSupported

Fully supported.

SafariSupported

Fully supported.

EdgeSupported

Fully supported.

Accessibility (A11y)

1Prefer Median for Skewed Distributions

Reporting mean() alone on skewed data (like income or transaction size) can mislead readers; pairing it with median() gives a more honest, interpretable summary for anyone consuming the report.

print(df['revenue'].mean(), df['revenue'].median())

SEO Implications

  • 1

    High-Intent Reference Content

    Searches like 'pandas describe explained' and 'pandas mean vs median' are common among people doing exploratory data analysis, making accurate, example-driven coverage of these methods valuable for organic search.

Best Practices

Start Every Analysis With describe()

Before writing any transformation logic, run df.describe() to catch obvious issues — unexpected ranges, missing counts, or columns that look numeric but aren't.

Pick the Right Central Tendency Metric

Use mean() for roughly symmetric data, median() when outliers could skew the average, and mode() for categorical or discrete data where 'most common value' is the meaningful question.

Frequent Bugs

THE BUG

Calling describe() and assuming it covers text columns, missing that non-numeric columns are silently excluded by default.

THE FIX

Pass describe(include='all') or describe(include='object') to also get count, unique, top, and freq statistics for categorical columns.

Real-World Examples

Spotting Skew Before Reporting an Average

A sales report shows a mean order value of $340, but most customers actually spend far less because a handful of enterprise orders are pulling the average up.

print(df['order_value'].mean())   # 340.12 — skewed by outliers
print(df['order_value'].median()) # 89.50 — what a typical customer pays

Interview Prep

?Frequently Asked Questions

Pascual Vila

Pascual Vila

Frontend Instructor // Code Syllabus

Common Pitfalls & Errors

The Error //

Reporting mean() on skewed data without checking for outliers

# Misleading: one huge order skews the average print(df['order_value'].mean()) # 340.12 # Better: check the median too print(df['order_value'].median()) # 89.50

The Solution //

A small number of extreme values can pull the mean far from what's typical. Compare mean() and median() before reporting a single 'average' figure, and use median() when they diverge significantly.

The Error //

Calling describe() and assuming numeric-only output covers the whole dataset

# Wrong: only numeric columns are summarized, text columns vanish df.describe() # Correct: include categorical columns too df.describe(include='all')

The Solution //

describe() silently drops non-numeric columns by default, so text/categorical fields never appear in the summary unless you ask for them explicitly.

Lesson Glossary

[01]Percentile (Quartile)

A score below which a given percentage of scores in its frequency distribution falls.

Code Preview
// Percentile (Quartile) context

[02]Standard Deviation (std)

A measure of the amount of variation or dispersion of a set of values.

Code Preview
// Standard Deviation (std) context

Continue Learning