Recall & Review
beginner
What does the
duplicated() function in pandas do?It returns a Boolean Series indicating whether each row is a duplicate of a previous row in the DataFrame.
Click to reveal answer
beginner
How can you use
duplicated() to find all duplicate rows except the first occurrence?By default,
duplicated() marks duplicates as True except for the first occurrence, which is False.Click to reveal answer
intermediate
What parameter of
duplicated() controls which duplicates are marked as True?The
keep parameter controls this. It can be 'first' (default), 'last', or False to mark all duplicates as True.Click to reveal answer
intermediate
How do you find duplicates based on specific columns using
duplicated()?Use the
subset parameter to specify columns to check for duplicates instead of the entire row.Click to reveal answer
intermediate
What is the difference between
duplicated() and drop_duplicates()?duplicated() returns a Boolean mask showing duplicates, while drop_duplicates() returns a DataFrame with duplicates removed.Click to reveal answer
What does
df.duplicated() return?✗ Incorrect
duplicated() returns a Boolean Series marking duplicates as True except the first occurrence.Which
keep parameter value marks all duplicates as True in duplicated()?✗ Incorrect
Setting
keep=False marks all duplicates as True.How do you check duplicates based on only some columns?
✗ Incorrect
The
subset parameter lets you specify columns to check for duplicates.What does
df.duplicated(keep='last') do?✗ Incorrect
With
keep='last', all duplicates except the last occurrence are marked True.Which function returns a DataFrame with duplicates removed?
✗ Incorrect
drop_duplicates() returns a DataFrame with duplicates removed.Explain how to use
duplicated() to find duplicate rows in a DataFrame and how to customize which duplicates are marked.Think about which rows are marked True and how to change that.
You got /4 concepts.
Describe the difference between
duplicated() and drop_duplicates() and when you might use each.Consider output type and purpose.
You got /4 concepts.