Complete the code to remove duplicate rows from the DataFrame df.
df_unique = df.[1]()The drop_duplicates() method removes duplicate rows from a DataFrame.
Complete the code to remove duplicates based only on the 'Name' column.
df_unique = df.drop_duplicates(subset=[1])The subset parameter specifies which columns to consider when identifying duplicates. Here, only 'Name' is used.
Fix the error in the code to remove duplicates and keep the last occurrence.
df_unique = df.drop_duplicates(keep=[1])The keep='last' option keeps the last occurrence of duplicates and removes earlier ones.
Fill both blanks to remove duplicates based on 'City' and keep only the first occurrence.
df_unique = df.drop_duplicates(subset=[1], keep=[2])
Use subset=['City'] to check duplicates by city, and keep='first' to keep the first occurrence.
Fill all three blanks to create a dictionary with names as keys and ages as values, only for unique names.
unique_ages = { [3].[1]: [3].[2] for [3] in df.drop_duplicates(subset=['Name']).itertuples() }This dictionary comprehension uses row to iterate over unique rows by 'Name', then maps row.Name to row.Age.