duplicated()
noun
say it: “DOO-plih-kay-tid” /ˈdupləˌkeɪtɪd/
A pandas method that marks each row that repeats an earlier row, comparing every column or only the columns you name.
What does duplicated() do in pandas?
duplicated() answers True for each row that repeats a row above it and False for the rest, so .sum() counts the
copies. With no subset, every column must match; subset= names the columns that make two rows the same event.
same_day = intake.duplicated(subset=["animal_id", "intake_date"])
print(same_day.sum()) # how many rows repeat an earlier one
In a sentence
- “duplicated() found 12 rows that were typed in twice.”
- “With subset set to the animal and the date, duplicated() caught the copies that differed only in a typo.”
Level: Journeyman · More Python terms at this level
Updated