0
0
Data Analysis Pythondata~10 mins

Why DataFrame is the core data structure in Data Analysis Python - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a DataFrame from a dictionary.

Data Analysis Python
import pandas as pd
data = {'Name': ['Alice', 'Bob'], 'Age': [25, 30]}
df = pd.[1](data)
print(df)
Drag options to blanks, or click blank then click option'
ADataFrame
BSeries
Carray
Dlist
Attempts:
3 left
💡 Hint
Common Mistakes
Using Series instead of DataFrame
Trying to create DataFrame with list directly
2fill in blank
medium

Complete the code to select the 'Age' column from the DataFrame.

Data Analysis Python
import pandas as pd
data = {'Name': ['Alice', 'Bob'], 'Age': [25, 30]}
df = pd.DataFrame(data)
age_column = df[1]['Age']
print(age_column)
Drag options to blanks, or click blank then click option'
A.at
B.loc
C[
D.iloc
Attempts:
3 left
💡 Hint
Common Mistakes
Using .iloc for label selection
Using .at which is for single values
3fill in blank
hard

Fix the error in the code to filter rows where Age is greater than 25.

Data Analysis Python
import pandas as pd
data = {'Name': ['Alice', 'Bob', 'Charlie'], 'Age': [25, 30, 22]}
df = pd.DataFrame(data)
filtered = df[df['Age'] [1] 25]
print(filtered)
Drag options to blanks, or click blank then click option'
A>
B<
C==
D<=
Attempts:
3 left
💡 Hint
Common Mistakes
Using < instead of >
Using == which checks equality
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps names to ages for people older than 23.

Data Analysis Python
data = {'Name': ['Alice', 'Bob', 'Charlie'], 'Age': [25, 30, 22]}
result = {data['Name'][i]: data['Age'][i] for i in range(len(data['Name'])) if data['Age'][i] [1] 23}
print(result)
Drag options to blanks, or click blank then click option'
A<
B>
C==
D!=
Attempts:
3 left
💡 Hint
Common Mistakes
Using < which selects ages less than 23
Using == which selects only age 23
5fill in blank
hard

Fill all three blanks to create a DataFrame from a list of dictionaries and select rows where score is above 80.

Data Analysis Python
import pandas as pd
data = [{'name': 'Alice', 'score': 85}, {'name': 'Bob', 'score': 75}, {'name': 'Cara', 'score': 90}]
df = pd.[1](data)
high_scores = df[df['[2]'] [3] 80]
print(high_scores)
Drag options to blanks, or click blank then click option'
ADataFrame
Bscore
C>
DSeries
Attempts:
3 left
💡 Hint
Common Mistakes
Using Series instead of DataFrame
Selecting wrong column name
Using < instead of >