Skip to content

Practice Drop Duplicate Rows

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#2882
LeetCode Problem

Drop Duplicate Rows

Problem Statement

The customers DataFrame has customer_id (int), name (object) and email (object) columns. Remove rows whose email duplicates an earlier row, keeping the first occurrence of each email. Return the remaining rows with their existing columns.

Source: Drop Duplicate Rows on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
+-------------+---------+---------------------+ | customer_id | name    | email               | +-------------+---------+---------------------+ | 1           | Ella    | emily@example.com   | | 2           | David   | michael@example.com | | 3           | Zachary | sarah@example.com   | | 4           | Alice   | john@example.com    | | 5           | Finn    | john@example.com    | | 6           | Violet  | alice@example.com   | +-------------+---------+---------------------+
Output
+-------------+---------+---------------------+ | customer_id | name    | email               | +-------------+---------+---------------------+ | 1           | Ella    | emily@example.com   | | 2           | David   | michael@example.com | | 3           | Zachary | sarah@example.com   | | 4           | Alice   | john@example.com    | | 6           | Violet  | alice@example.com   | +-------------+---------+---------------------+

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.