0
0
Pandasdata~20 mins

What is Pandas - Practice Questions & Exercises

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Pandas Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:00remaining
Understanding the Purpose of Pandas

What is the main purpose of the Pandas library in data science?

ATo build machine learning models
BTo create interactive web pages
CTo manipulate and analyze data easily
DTo design computer graphics
Attempts:
2 left
💡 Hint

Think about what you do with tables of data in Python.

Predict Output
intermediate
1:30remaining
Pandas DataFrame Creation Output

What will be the output of this code?

Pandas
import pandas as pd

df = pd.DataFrame({'A': [1, 2], 'B': [3, 4]})
print(df)
A
   A  B
0  1  3
1  2  4
BError: DataFrame not defined
C{'A': [1, 2], 'B': [3, 4]}
D[[1, 3], [2, 4]]
Attempts:
2 left
💡 Hint

Look at how DataFrame prints tabular data.

data_output
advanced
1:30remaining
Selecting Data from a DataFrame

Given the DataFrame below, what is the output of df['B'][1]?

Pandas
import pandas as pd

df = pd.DataFrame({'A': [10, 20, 30], 'B': [100, 200, 300]})
A100
BKeyError
C30
D200
Attempts:
2 left
💡 Hint

Remember that df['B'] selects column B, then [1] selects the second row.

visualization
advanced
2:00remaining
Plotting with Pandas

What type of plot will this code produce?

Pandas
import pandas as pd
import matplotlib.pyplot as plt

df = pd.DataFrame({'x': [1, 2, 3], 'y': [4, 5, 6]})
df.plot(x='x', y='y', kind='bar')
plt.show()
AA bar chart showing y values for each x
BA line chart connecting points (x, y)
CA scatter plot of x vs y
DA pie chart of y values
Attempts:
2 left
💡 Hint

The kind='bar' argument controls the plot type.

🔧 Debug
expert
1:30remaining
Error Identification in Pandas Code

What error will this code raise?

Pandas
import pandas as pd

df = pd.DataFrame({'A': [1, 2], 'B': [3, 4]})
print(df['C'])
ATypeError
BKeyError
CIndexError
DNo error, prints empty column
Attempts:
2 left
💡 Hint

Check if column 'C' exists in the DataFrame.