0
0
Pandasdata~20 mins

describe() for statistical summary in Pandas - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Describe Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of describe() on numeric DataFrame
What is the output of the following code snippet?
Pandas
import pandas as pd
import numpy as np
data = pd.DataFrame({'A': [1, 2, 3, 4, 5], 'B': [5, 4, 3, 2, 1]})
summary = data.describe()
print(summary)
A{'A': {'count': 5.0, 'mean': 3.0, 'std': 1.58, 'min': 1.0, '25%': 2.0, '50%': 3.0, '75%': 4.0, 'max': 5.0}, 'B': {'count': 5.0, 'mean': 3.0, 'std': 1.58, 'min': 1.0, '25%': 2.0, '50%': 3.0, '75%': 4.0, 'max': 5.0}}
BA DataFrame with count=5, mean=3, std=1.58, min=1, 25%=2, 50%=3, 75%=4, max=5 for column A and count=5, mean=3, std=1.58, min=5, 25%=4, 50%=3, 75%=2, max=1 for column B
CA DataFrame with count=5, mean=3, std=1.58, min=1, 25%=2, 50%=3, 75%=4, max=5 for both columns
DA DataFrame with count=5, mean=3, std=1.58, min=1, 25%=2, 50%=3, 75%=4, max=5 for column A and reversed for B
Attempts:
2 left
💡 Hint
The describe() method returns a summary with count, mean, std, min, quartiles, and max for numeric columns.
data_output
intermediate
1:30remaining
Count of non-numeric columns in describe() output
Given the DataFrame below, how many columns will appear in the output of describe() by default?
Pandas
import pandas as pd
data = pd.DataFrame({'Name': ['Alice', 'Bob', 'Charlie'], 'Age': [25, 30, 35], 'City': ['NY', 'LA', 'SF']})
summary = data.describe()
print(summary)
A2
B1
C3
D0
Attempts:
2 left
💡 Hint
By default, describe() summarizes only numeric columns.
🧠 Conceptual
advanced
1:30remaining
Understanding percentiles in describe()
Which of the following statements about the percentiles shown in describe() output is TRUE?
AThe 50% value is the median of the data.
BThe 25% and 75% values represent the mean minus and plus one standard deviation.
CThe 25%, 50%, and 75% values are the minimum, median, and maximum respectively.
DPercentiles in describe() are calculated only for categorical columns.
Attempts:
2 left
💡 Hint
Think about what the 50% percentile means in statistics.
🔧 Debug
advanced
1:30remaining
Error when calling describe() on empty DataFrame
What error will this code produce?
Pandas
import pandas as pd
data = pd.DataFrame()
summary = data.describe()
print(summary)
AEmpty DataFrame with no columns and no rows
BTypeError: describe() missing required argument
CValueError: No numeric types to describe
DKeyError: 'describe'
Attempts:
2 left
💡 Hint
What does describe() return if the DataFrame has no data?
🚀 Application
expert
2:30remaining
Using describe() to compare two groups
You have a DataFrame with a numeric column 'Score' and a categorical column 'Group' with values 'A' and 'B'. Which code snippet correctly produces descriptive statistics of 'Score' for each group separately?
Adata.describe().groupby('Group')['Score']
Bdata.describe('Score').groupby('Group')
Cdata['Score'].describe().groupby(data['Group'])
Ddata.groupby('Group')['Score'].describe()
Attempts:
2 left
💡 Hint
Think about how to group data before summarizing.