0
0
Data Analysis Pythondata~10 mins

Creating interaction features in Data Analysis Python - Interactive Practice

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

Complete the code to create a new feature by multiplying 'age' and 'income'.

Data Analysis Python
df['age_income'] = df['age'] [1] df['income']
Drag options to blanks, or click blank then click option'
A+
B-
C*
D/
Attempts:
3 left
💡 Hint
Common Mistakes
Using '+' instead of '*' which adds instead of multiplies.
Using '/' which divides and may cause errors if denominator has zeros.
2fill in blank
medium

Complete the code to create an interaction feature by concatenating 'city' and 'job' as strings.

Data Analysis Python
df['city_job'] = df['city'] [1] df['job']
Drag options to blanks, or click blank then click option'
A//
B*
C-
D+
Attempts:
3 left
💡 Hint
Common Mistakes
Using '*' which causes an error for strings.
Using '-' which is invalid for strings.
3fill in blank
hard

Fix the error in the code to create an interaction feature by multiplying 'height' and 'weight'.

Data Analysis Python
df['height_weight'] = df['height'] [1] df['weight']
Drag options to blanks, or click blank then click option'
A*
B-
C+
D/
Attempts:
3 left
💡 Hint
Common Mistakes
Using '+' which adds instead of multiplying.
Using '/' which divides and is incorrect here.
4fill in blank
hard

Fill both blanks to create a dictionary of word lengths for words longer than 3 characters.

Data Analysis Python
lengths = {word: [1] for word in words if len(word) [2] 3}
Drag options to blanks, or click blank then click option'
Alen(word)
B>
C<
Dword
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' instead of '>' causing wrong filtering.
Using 'word' instead of 'len(word)' for the value.
5fill in blank
hard

Fill all three blanks to create a dictionary with uppercase keys and values greater than zero.

Data Analysis Python
result = { [1]: [2] for k, v in data.items() if v [3] 0}
Drag options to blanks, or click blank then click option'
Ak.upper()
Bv
C>
Dk
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'k' instead of 'k.upper()' for keys.
Using '<' or other operators instead of '>' for filtering.
Using 'k' as value instead of 'v'.