Challenge - 5 Problems
Excel Reading Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output of this code reading an Excel file?
Consider an Excel file named
data.xlsx with a sheet named Sheet1 containing a column Age with values [25, 30, 35]. What will be the output of the following code?Data Analysis Python
import pandas as pd df = pd.read_excel('data.xlsx', sheet_name='Sheet1') print(df['Age'].tolist())
Attempts:
2 left
💡 Hint
Think about how pandas reads numeric columns from Excel.
✗ Incorrect
The code reads the Excel sheet correctly and extracts the 'Age' column as integers, so the list is [25, 30, 35].
❓ data_output
intermediate2:00remaining
What data is loaded with this read_excel call?
Given an Excel file
sales.xlsx with sheets Q1 and Q2, each having columns Product and Sales. What will be the shape of the DataFrame loaded by this code?Data Analysis Python
import pandas as pd df = pd.read_excel('sales.xlsx', sheet_name='Q2') print(df.shape)
Attempts:
2 left
💡 Hint
Assume Q2 sheet has 10 rows and 2 columns.
✗ Incorrect
The DataFrame shape is (10, 2) because Q2 sheet has 10 rows and 2 columns.
🔧 Debug
advanced2:00remaining
What error does this code raise when reading an Excel file?
What error will this code produce if the file
missing.xlsx does not exist in the folder?Data Analysis Python
import pandas as pd df = pd.read_excel('missing.xlsx')
Attempts:
2 left
💡 Hint
Think about what happens when a file is missing.
✗ Incorrect
If the file is missing, Python raises FileNotFoundError.
🧠 Conceptual
advanced2:00remaining
Which option correctly reads only columns 'Name' and 'Age' from an Excel file?
You want to read only the columns 'Name' and 'Age' from
people.xlsx. Which code does this correctly?Attempts:
2 left
💡 Hint
Check the correct parameter name for selecting columns.
✗ Incorrect
The parameter to select columns is 'usecols'. Other options are invalid.
🚀 Application
expert3:00remaining
What is the output of this code reading multiple sheets into a dictionary?
Given an Excel file
multi_sheets.xlsx with sheets Jan and Feb, each with 3 rows and 2 columns, what will be the output of this code?Data Analysis Python
import pandas as pd sheets = pd.read_excel('multi_sheets.xlsx', sheet_name=['Jan', 'Feb']) print(len(sheets), sheets['Jan'].shape, sheets['Feb'].shape)
Attempts:
2 left
💡 Hint
Reading multiple sheets returns a dictionary with sheet names as keys.
✗ Incorrect
The variable sheets is a dict with 2 keys. Each DataFrame has shape (3, 2).