0
0
Data Analysis Pythondata~20 mins

describe() for statistics in Data Analysis Python - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Describe Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of describe() on numeric data
What is the output of the describe() method on this DataFrame's numeric column?
Data Analysis Python
import pandas as pd

df = pd.DataFrame({'scores': [10, 20, 20, 30, 40]})
result = df['scores'].describe()
print(result)
A
count    5.0
mean    24.0
std     12.25
min     10.0
25%     15.0
50%     20.0
75%     30.0
max     40.0
Name: scores, dtype: float64
B
count    5
mean    24
std     12.25
min     10
25%     20
50%     20
75%     30
max     40
Name: scores, dtype: int64
C
count    5.0
mean    24.0
std     11.40
min     10.0
25%     20.0
50%     20.0
75%     30.0
max     40.0
Name: scores, dtype: float64
D
count    5.0
mean    24.0
std     10.0
min     10.0
25%     20.0
50%     20.0
75%     30.0
max     40.0
Name: scores, dtype: float64
Attempts:
2 left
💡 Hint
Remember that describe() returns count, mean, std, min, quartiles, and max for numeric data.
data_output
intermediate
2:00remaining
describe() on categorical data output
What does describe() return when applied to a categorical column in a DataFrame?
Data Analysis Python
import pandas as pd

df = pd.DataFrame({'colors': ['red', 'blue', 'red', 'green', 'blue', 'blue']})
result = df['colors'].describe()
print(result)
A
count       6
unique      3
top       blue
freq        3
Name: colors, dtype: object
B
count       6
mean      NaN
std       NaN
min       blue
max       red
Name: colors, dtype: object
C
count       6
unique      4
top       red
freq        2
Name: colors, dtype: object
D
count       6
unique      3
top       green
freq        1
Name: colors, dtype: object
Attempts:
2 left
💡 Hint
For categorical data, describe() shows count, unique values, most frequent value (top), and its frequency (freq).
🧠 Conceptual
advanced
1:30remaining
Understanding describe() output for mixed data
If a DataFrame has both numeric and categorical columns, what does describe() return by default?
AIt returns descriptive statistics only for numeric columns.
BIt returns descriptive statistics for all columns, numeric and categorical combined in one table.
CIt returns descriptive statistics only for categorical columns.
DIt raises an error because of mixed data types.
Attempts:
2 left
💡 Hint
By default, describe() focuses on numeric data unless specified otherwise.
🔧 Debug
advanced
1:30remaining
Error when calling describe() on empty DataFrame
What error occurs when calling describe() on an empty DataFrame with no columns?
Data Analysis Python
import pandas as pd

df = pd.DataFrame()
result = df.describe()
print(result)
AAttributeError: 'DataFrame' object has no attribute 'describe'
B
Empty DataFrame
Columns: []
Index: []
CTypeError: describe() missing 1 required positional argument
DValueError: No objects to describe
Attempts:
2 left
💡 Hint
Check what pandas returns when describe() is called on an empty DataFrame.
🚀 Application
expert
2:30remaining
Using describe() to compare two datasets
You have two DataFrames df1 and df2 with a numeric column 'age'. You want to quickly compare their age distributions. Which code snippet correctly prints the summary statistics side by side?
Data Analysis Python
import pandas as pd

df1 = pd.DataFrame({'age': [23, 45, 31, 35, 40]})
df2 = pd.DataFrame({'age': [30, 22, 40, 50, 60]})
Aprint(df1['age'].describe().merge(df2['age'].describe()))
Bprint(df1['age'].describe() + df2['age'].describe())
Cprint(df1['age'].describe().append(df2['age'].describe()))
Dprint(pd.concat([df1['age'].describe(), df2['age'].describe()], axis=1))
Attempts:
2 left
💡 Hint
Think about how to combine two Series objects side by side in pandas.