Challenge - 5 Problems
Info() Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ data_output
intermediate2:00remaining
Output of info() on DataFrame with mixed types
Given the following DataFrame, what will be the output of
df.info()?Data Analysis Python
import pandas as pd df = pd.DataFrame({ 'A': [1, 2, 3], 'B': ['x', 'y', 'z'], 'C': [1.1, 2.2, 3.3], 'D': [True, False, True] }) df.info()
Attempts:
2 left
💡 Hint
Look carefully at the default data types pandas assigns to each column based on the data.
✗ Incorrect
Pandas assigns int64 to integer columns, object to string columns, float64 to float columns, and bool to boolean columns by default. The info() method shows these types along with counts and memory usage.
🧠 Conceptual
intermediate1:30remaining
Understanding info() output for missing data
If a DataFrame column has some missing values, how does
info() display the count for that column?Attempts:
2 left
💡 Hint
Think about what 'Non-Null Count' means in the info() output.
✗ Incorrect
The info() method displays the number of non-null values per column, which means it counts only the entries that are not missing.
❓ Predict Output
advanced2:00remaining
Output of info() after type conversion
What will be the output of
df.info() after converting column 'B' to category type?Data Analysis Python
import pandas as pd df = pd.DataFrame({ 'A': [10, 20, 30], 'B': ['cat', 'dog', 'cat'] }) df['B'] = df['B'].astype('category') df.info()
Attempts:
2 left
💡 Hint
Check what happens when you convert a column to 'category' dtype in pandas.
✗ Incorrect
Converting a column to 'category' changes its dtype shown in info() to 'category' and increases memory usage slightly.
🔧 Debug
advanced1:30remaining
Identify the error in info() usage
What error will occur if you try to call
df.info without parentheses?Data Analysis Python
import pandas as pd df = pd.DataFrame({'X': [1, 2, 3]}) print(df.info)
Attempts:
2 left
💡 Hint
Think about what happens when you print a method without calling it.
✗ Incorrect
Printing df.info without parentheses prints the method object itself, not the info output.
🚀 Application
expert2:30remaining
Using info() to find columns with missing data
You want to find which columns in a DataFrame have missing values by using
info(). Which approach below correctly identifies columns with missing data?Data Analysis Python
import pandas as pd df = pd.DataFrame({ 'A': [1, None, 3], 'B': ['x', 'y', 'z'], 'C': [None, None, 3.3] }) # Which code snippet below helps identify columns with missing values using info() output?
Attempts:
2 left
💡 Hint
Missing values reduce the non-null count shown by info().
✗ Incorrect
Columns with missing data have fewer non-null entries than total rows, so comparing these counts reveals missing data.