Challenge - 5 Problems
Describe Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2: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)
Attempts:
2 left
💡 Hint
The describe() method returns a summary with count, mean, std, min, quartiles, and max for numeric columns.
✗ Incorrect
The describe() method returns a DataFrame summarizing count, mean, standard deviation, min, 25th percentile, median (50%), 75th percentile, and max for each numeric column. Both columns A and B have the same statistics because B is just A reversed.
❓ data_output
intermediate1: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)
Attempts:
2 left
💡 Hint
By default, describe() summarizes only numeric columns.
✗ Incorrect
By default, describe() includes only numeric columns. Here, 'Age' is numeric, 'Name' and 'City' are strings, so only 1 column appears.
🧠 Conceptual
advanced1:30remaining
Understanding percentiles in describe()
Which of the following statements about the percentiles shown in describe() output is TRUE?
Attempts:
2 left
💡 Hint
Think about what the 50% percentile means in statistics.
✗ Incorrect
The 50% percentile is the median, the middle value of the sorted data. The 25% and 75% are the first and third quartiles, not related to mean and std. Percentiles are for numeric data.
🔧 Debug
advanced1: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)
Attempts:
2 left
💡 Hint
What does describe() return if the DataFrame has no data?
✗ Incorrect
Calling describe() on an empty DataFrame returns an empty DataFrame with no columns and no rows, no error is raised.
🚀 Application
expert2: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?
Attempts:
2 left
💡 Hint
Think about how to group data before summarizing.
✗ Incorrect
Using groupby on 'Group' and then calling describe() on 'Score' gives descriptive stats for each group separately.