0
0
Data Analysis Pythondata~10 mins

Selecting columns in Data Analysis Python - Interactive Code Practice

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

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

Data Analysis Python
selected = df[[1]]
Drag options to blanks, or click blank then click option'
A['age']
Bage
C'Age'
D'age'
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around the column name.
Using a variable name without quotes.
Using a list instead of a string for a single column.
2fill in blank
medium

Complete the code to select multiple columns 'name' and 'score' from the DataFrame.

Data Analysis Python
selected = df[[1]]
Drag options to blanks, or click blank then click option'
A['name', 'score']
B'name, score'
C('name', 'score')
D{'name', 'score'}
Attempts:
3 left
💡 Hint
Common Mistakes
Using a string with commas instead of a list.
Using parentheses or curly braces instead of square brackets.
Not using quotes around column names.
3fill in blank
hard

Fix the error in the code to select the 'height' column from the DataFrame.

Data Analysis Python
selected = df.[1]
Drag options to blanks, or click blank then click option'
A['height']
B'height'
Cheight
D[height]
Attempts:
3 left
💡 Hint
Common Mistakes
Putting quotes around the column name with dot notation.
Using brackets with dot notation.
Using a list or string incorrectly.
4fill in blank
hard

Fill both blanks to create a dictionary with word lengths for words longer than 3 letters.

Data Analysis Python
lengths = { [1] : [2] for word in words if len(word) > 3 }
Drag options to blanks, or click blank then click option'
Aword
Blen(word)
Cword.upper()
Dlen(words)
Attempts:
3 left
💡 Hint
Common Mistakes
Using the length of the whole list instead of each word.
Using uppercase words as keys instead of original words.
Swapping keys and values.
5fill in blank
hard

Fill all three blanks to create a dictionary with uppercase keys and values for words longer than 4 letters.

Data Analysis Python
result = { [1] : [2] for word in words if len(word) [3] 4 }
Drag options to blanks, or click blank then click option'
Aword.upper()
Bword
C>
Dlen(word)
Attempts:
3 left
💡 Hint
Common Mistakes
Using length as a key or value incorrectly.
Using wrong comparison operators.
Not converting keys to uppercase.