Complete the code to convert a text column to lowercase.
df['text'] = df['text'].[1]()
Using lower() converts all text to lowercase, which helps standardize text data for analysis.
Complete the code to remove punctuation from a text string using Python's string module.
import string text = 'Hello, world!' clean_text = ''.join(char for char in text if char not in [1])
string.punctuation contains all punctuation characters. Filtering them out cleans the text.
Fix the error in the code to split text into words correctly.
text = 'Data science is fun' words = text.[1](' ')
The split(' ') method breaks the string into a list of words separated by spaces.
Fill both blanks to create a dictionary of word lengths for words longer than 3 characters.
words = ['data', 'is', 'fun', 'science'] lengths = {word: [1] for word in words if len(word) [2] 3}
We use len(word) to get word length and filter words with length greater than 3.
Fill all three blanks to create a dictionary of uppercase words with length greater than 2.
words = ['cat', 'is', 'big', 'dog'] result = [1] for word in words if len(word) [2] 2] result = {w.[3](): w for w in result}
First, we create a list of words with length greater than 2 using a list comprehension starting with [word.upper(). Then we filter with >. Finally, we create a dictionary with keys as uppercase words using upper method.