0
0
Data Analysis Pythondata~20 mins

Reading Excel files (read_excel) in Data Analysis Python - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Excel Reading Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2: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())
A['25', '30', '35']
B[25, 30, 35, None]
C[25, 30, 35]
DKeyError: 'Age'
Attempts:
2 left
💡 Hint
Think about how pandas reads numeric columns from Excel.
data_output
intermediate
2: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)
A(10, 2)
B(2, 10)
C(0, 0)
DFileNotFoundError
Attempts:
2 left
💡 Hint
Assume Q2 sheet has 10 rows and 2 columns.
🔧 Debug
advanced
2: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')
AFileNotFoundError
BValueError
CKeyError
DTypeError
Attempts:
2 left
💡 Hint
Think about what happens when a file is missing.
🧠 Conceptual
advanced
2: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?
Apd.read_excel('people.xlsx', cols=['Name', 'Age'])
Bpd.read_excel('people.xlsx', columns=['Name', 'Age'])
Cpd.read_excel('people.xlsx', select=['Name', 'Age'])
Dpd.read_excel('people.xlsx', usecols=['Name', 'Age'])
Attempts:
2 left
💡 Hint
Check the correct parameter name for selecting columns.
🚀 Application
expert
3: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)
A2 (2, 3) (2, 3)
B2 (3, 2) (3, 2)
C1 (3, 2) (3, 2)
DKeyError: 'Jan'
Attempts:
2 left
💡 Hint
Reading multiple sheets returns a dictionary with sheet names as keys.