0
0
Pandasdata~10 mins

str.split() for splitting in Pandas - Interactive Code Practice

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

Complete the code to split the 'Name' column by spaces.

Pandas
df['Name_split'] = df['Name'].str.[1](' ')
Drag options to blanks, or click blank then click option'
Asplit
Bjoin
Creplace
Dstrip
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'join' instead of 'split'.
Forgetting to specify the separator.
Using 'replace' which changes text but does not split.
2fill in blank
medium

Complete the code to split the 'Address' column by commas.

Pandas
df['Address_parts'] = df['Address'].str.[1](',')
Drag options to blanks, or click blank then click option'
Asplit
Bstrip
Cfind
Dreplace
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'replace' which changes commas but does not split.
Using 'find' which only locates text but does not split.
3fill in blank
hard

Fix the error in splitting the 'Data' column by semicolon.

Pandas
df['Data_split'] = df['Data'].str.[1](';')
Drag options to blanks, or click blank then click option'
Ajoin
Bstrip
Csplit
Dreplace
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'join' which causes an error here.
Using 'replace' which does not split.
4fill in blank
hard

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

Pandas
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 '>' in the condition.
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 0.

Pandas
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 '<' instead of '>' in the condition.