Descriptive Statistics and Value Counts
After cleaning and preparing your DataFrame, the next step is to explore the distribution and summary of your data.
Pandas offers straightforward yet powerful tools for generating quick statistical overviews โ helping you identify trends, anomalies, and insights with ease.
Descriptive Methods
Use .describe() to get a quick statistical summary of all numeric columns:
- Count of non-null values
- Mean and standard deviation
- Minimum and maximum values
- 25%, 50%, and 75% percentiles
This method is your go-to tool for initial data exploration and profiling.
Categorical Analysis with value_counts()
To summarize non-numeric (categorical) columns, use .value_counts().
It returns the frequency of each unique value in a column.
df = pd.DataFrame({ "Category": ["A", "A", "B", "B", "C", "C"] }) df["Category"].value_counts() # Output: # B 2 # A 2 # C 2
Common Additional Methods
| Method | Purpose |
|---|---|
mean() | Average value |
median() | Middle value |
std() | Standard deviation |
min() / max() | Minimum and maximum values |
sum() | Total sum of column |
count() | Number of non-null entries |
You can apply these methods to individual columns or across the entire DataFrame to gain a deeper statistical understanding of your dataset.
Lessons in this chapter ยท Taming Data with Pandas
- 1. Introduction to Pandas and DataFrames
- 2. Creating and Inspecting Series and DataFrames
- 3. Selecting Columns and Rows
- 4. Filtering with Boolean Conditions
- 5. Updating and Modifying Data
- 6. Anatomy of a DataFrame
- 7. Multiple-choice quiz
- 8. Handling Missing and Duplicate Data
- 9. Sorting, Ranking, and Reindexing
- 10. GroupBy and Aggregation Functions
- 11. Merging and Joining DataFrames
- 12. Descriptive Statistics and Value Counts
- 13. Working with Date and Time Columns
- 14. Fill-in-the-blank quiz
Which method in pandas is used to get a quick statistical summary of all numeric columns in a DataFrame?
.value_counts()
.mean()
.describe()
.sum()
Lecture
AI Tutor
Design
Upload
Notes
Favorites
Help