Complete the code to drop duplicate rows keeping the first occurrence.
df_unique = df.drop_duplicates(keep=[1])Using keep="first" keeps the first occurrence of duplicates and drops the rest.
Complete the code to drop duplicate rows keeping the last occurrence.
df_unique = df.drop_duplicates(keep=[1])Using keep="last" keeps the last occurrence of duplicates and drops the earlier ones.
Fix the error in the code to drop all duplicates (keep none).
df_unique = df.drop_duplicates(keep=[1])Using keep=False drops all duplicates, keeping none.
Fill both blanks to create a dictionary of word lengths for words longer than 3 characters.
lengths = {word: [1] for word in words if len(word) [2] 3 }The dictionary comprehension maps each word to its length if the word length is greater than 3.
Fill all three blanks to create a dictionary with uppercase keys and values greater than zero.
result = { [1]: [2] for k, v in data.items() if v [3] 0 }This dictionary comprehension creates keys as uppercase strings and includes only items where the value is greater than zero.