Complete the code to convert the 'name' column in the DataFrame to lowercase using the string accessor.
df['name_lower'] = df['name'].str.[1]()
The str.lower() method converts all characters in the string to lowercase.
Complete the code to check if the 'email' column contains the '@' symbol using the string accessor.
df['has_at'] = df['email'].str.[1]('@')
The str.contains() method checks if the string contains a specific substring.
Fix the error in the code to extract the first 3 characters from the 'code' column using the string accessor.
df['code_start'] = df['code'].str.[1](0, 3)
The str.slice(0, 3) method extracts a substring from index 0 up to but not including index 3.
Fill both blanks to create a new column with the 'city' names trimmed of whitespace and converted to uppercase.
df['city_clean'] = df['city'].str.[1]().str.[2]()
First, str.strip() removes whitespace from both ends. Then, str.upper() converts text to uppercase.
Fill all three blanks to create a dictionary with words as keys and their lengths as values, but only for words longer than 4 characters.
lengths = { [1]: [2] for [3] in words if len([3]) > 4 }The dictionary comprehension uses word as key and len(word) as value, iterating over word in words.