2. Which of the following is the correct way to call describe() on a pandas DataFrame named df?
easy
A. df.describe()
B. describe(df)
C. df.describe
D. df.describe[]
Solution
Step 1: Recall pandas method syntax
Methods are called with parentheses after the method name, so df.describe() is correct.
Step 2: Check other options for syntax errors
df.describe[] uses invalid square brackets; describe(df) incorrectly calls it as a standalone function; df.describe misses parentheses and prints the method object.
Final Answer:
df.describe() -> Option A
Quick Check:
Method call needs () = df.describe() [OK]
Hint: Call methods with parentheses: df.describe() [OK]
B. describe is not a pandas function; import missing
C. Missing parentheses after describe; fix with df.describe()
D. Syntax error in DataFrame creation
Solution
Step 1: Identify the problem
The code references df.describe without parentheses, so it prints the method object, not the result.
Step 2: Fix the code
Add parentheses to call the method: df.describe().
Final Answer:
Missing parentheses after describe; fix with df.describe() -> Option C
Quick Check:
Method call needs () = df.describe() [OK]
Hint: Always use () to call methods [OK]
Common Mistakes:
Forgetting parentheses on method calls
Assuming describe is not a method
Thinking DataFrame needs more columns
5. You have a DataFrame df with numeric and categorical columns. You want describe() to include statistics for all columns, not just numeric ones. Which code will achieve this?
hard
A. df.describe(exclude='all')
B. df.describe(include='all')
C. df.describe(numeric_only=True)
D. df.describe(include='numeric')
Solution
Step 1: Understand describe() default behavior
By default, describe() shows stats only for numeric columns.
Step 2: Use include='all' to get all columns
Passing include='all' makes describe() summarize numeric and categorical columns.
Step 3: Check other options
exclude='all' excludes all columns (invalid result); numeric_only=True limits to numeric only; include='numeric' matches default.
Final Answer:
df.describe(include='all') -> Option B
Quick Check:
include='all' = all columns summary [OK]
Hint: Use include='all' to describe all columns [OK]
Common Mistakes:
Using numeric_only=True to get all columns
Confusing include and exclude parameters
Passing invalid values to include
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.