Multiple Summaries in Pandas – Advanced Aggregation Techniques 2026
When you need several different summary statistics across multiple columns, Pandas offers powerful and flexible ways to do it cleanly. In 2026, the combination of .agg(), named aggregations, and method chaining is the recommended approach for creating professional multi-summary reports.
TL;DR — Best Patterns for Multiple Summaries
- Use dictionary-style
.agg()for different functions per column - Use named aggregation syntax for clean, meaningful column names
- Combine with
groupby()for segmented multi-summaries - Use custom functions when built-in ones are not enough
1. Basic Multiple Summaries on Single DataFrame
import pandas as pd
df = pd.read_csv("sales_data.csv", parse_dates=["order_date"])
multi_summary = df.agg({
"amount": ["count", "sum", "mean", "median", "min", "max", "std"],
"quantity": ["sum", "mean", "max"],
"customer_id": ["nunique"],
"region": ["nunique"]
}).round(2)
print(multi_summary)
2. Grouped Multiple Summaries (Most Useful Pattern)
result = (
df
.groupby(["region", df["order_date"].dt.to_period("M")])
.agg({
"amount": ["sum", "mean", "count", "std"],
"quantity": ["sum", "mean"],
"customer_id": "nunique",
"product_id": "nunique"
})
.round(2)
)
# Clean column names
result.columns = [
"total_sales", "avg_sale", "order_count", "sales_std",
"total_quantity", "avg_quantity", "unique_customers", "unique_products"
]
print(result)
3. Named Aggregation – Cleanest & Most Recommended in 2026
monthly_report = (
df
.groupby(["region", df["order_date"].dt.to_period("M")])
.agg(
total_sales=("amount", "sum"),
average_sale=("amount", "mean"),
order_count=("amount", "count"),
total_quantity=("quantity", "sum"),
unique_customers=("customer_id", "nunique"),
sales_volatility=("amount", "std")
)
.round(2)
.reset_index()
)
print(monthly_report)
4. Using Custom Functions for Multiple Summaries
def coefficient_of_variation(x):
return x.std() / x.mean() if x.mean() != 0 else 0
summary = (
df
.groupby("region")
.agg(
total_revenue=("amount", "sum"),
avg_order_value=("amount", "mean"),
cv=("amount", coefficient_of_variation),
customer_diversity=("customer_id", "nunique")
)
.round(2)
)
Best Practices in 2026
- Prefer **named aggregation** syntax for readable and maintainable code
- Use method chaining to keep your aggregation logic clean
- Always round final results for professional-looking reports
- Define small custom functions when you need special calculations
- Use
.reset_index()when you want a flat table for further processing or export
Conclusion
Creating multiple summaries across several columns is a daily task in data manipulation. In 2026, using Pandas .agg() with named aggregation gives you the perfect balance of power, readability, and performance. Master this pattern and your summary reports will be both insightful and professionally formatted.
Next steps:
- Take one of your existing groupby operations and rewrite it using named aggregation syntax