Complete the code to apply the function to each element in the 'score' column using map().
df['score'] = df['score'].[1](lambda x: x + 10)
The map() function applies a given function to each element of the Series, transforming the data element-wise.
Complete the code to replace values in the 'grade' column using a mapping dictionary with map().
grade_map = {'A': 4, 'B': 3, 'C': 2}
df['grade_num'] = df['grade'].[1](grade_map)The map() function can take a dictionary to replace values element-wise in a Series.
Fix the error in the code to correctly map values in the 'status' column using map().
status_map = {1: 'Active', 0: 'Inactive'}
df['status_text'] = df['status'].[1](status_map)Using map() with a dictionary correctly replaces the numeric codes with text labels element-wise.
Fill both blanks to create a dictionary comprehension that maps words to their lengths, then apply it with map().
length_map = {word: [1] for word in words if len(word) [2] 3}
result = df['text'].map(length_map)The dictionary comprehension maps each word to its length if the word length is greater than 3. Then map() applies this mapping.
Fill all three blanks to create a dictionary comprehension mapping uppercase words to their lengths, then apply it with map().
length_map = [1]: [2] for word in words if word [3] word.upper() result = df['text'].map(length_map)
The dictionary comprehension maps each uppercase word to its length. The condition checks if the word is uppercase by comparing it to its uppercase version.