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...")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
Fully supported.
Fully supported.
Fully supported.
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
Calling describe() and assuming it covers text columns, missing that non-numeric columns are silently excluded by default.
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