0
0
Data Analysis Pythondata~10 mins

Why project-based learning cements skills 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 pd.Series instead of pd.DataFrame
Trying to use list or array which are not pandas constructors
2fill in blank
medium

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

Data Analysis Python
ages = df[1]
print(ages)
Drag options to blanks, or click blank then click option'
A.select('Age')
B['Age']
C.Age()
D[['Age']]
Attempts:
3 left
💡 Hint
Common Mistakes
Using double square brackets returns a DataFrame, not a Series
Using dot notation with parentheses is invalid
3fill in blank
hard

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

Data Analysis Python
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 equality operator instead of greater than
Using less than or less than or equal operators
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps words to their lengths for words longer than 3 letters.

Data Analysis Python
words = ['data', 'science', 'is', 'fun']
lengths = {word: [1] for word in words if [2]
print(lengths)
Drag options to blanks, or click blank then click option'
Alen(word)
Bword > 3
Clen(word) > 3
Dword
Attempts:
3 left
💡 Hint
Common Mistakes
Comparing the word string directly to a number
Using the word itself as the value instead of its length
5fill in blank
hard

Fill all three blanks to create a dictionary with uppercase keys and values filtered by value > 20.

Data Analysis Python
data = {'a': 10, 'b': 25, 'c': 30}
result = { [1]: [2] for k, v in data.items() if v [3] 20 }
print(result)
Drag options to blanks, or click blank then click option'
Ak.upper()
Bv
C>
Dk.lower()
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase keys instead of uppercase
Filtering with wrong comparison operator
Swapping keys and values