Summary Statistics
describe summarizes numeric columns with count, mean, std and quartiles. Use include="all" to add other columns.
Example
import pandas as pd
import numpy as np
df = pd.DataFrame({'name': ['Ada', 'Bob', 'Cy', 'Di'], 'age': [30, 25, 35, 28], 'city': ['Lagos', 'Accra', 'Lagos', 'Nairobi'], 'score': [88.5, 92.0, 79.5, 85.0]})
print(df.describe().round(2))
print(df['city'].describe())Result
age score count 4.00 4.00 mean 29.50 86.25 std 4.20 5.33 min 25.00 79.50 25% 27.25 83.62 50% 29.00 86.75 75% 31.25 89.38 max 35.00 92.00 count 4 unique 3 top Lagos freq 2 Name: city, dtype: object
Exercise
Summarize the table.
df.()
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.