dask / dask/dask

Support drop_duplicates(subset=...)

Open
#10,374 1 comment 0 reactions 0 assignees View on GitHub
dataframe feature needs attention
Dominant language
Python
Stars
13.9k
Forks
2k
PR merge metrics
No merged PRs in 30d

Description

(This is a little ramble-y. Sorry.)

Probably we could make drop_duplicates more scalable in the case where folks subset on columns. We would still probably have to fit information about every row for the relevant columns in memory, but this is quite different from reducing the entire dataset (all columns) to a single partition.

My thinking is that for each value of the subsetted columns we want to know that only a single partition will hold onto that value. One way to do this would be to build up a mapping of value to partition number like the following:

```python
df.drop_duplicates(subset=["id"])
```
```python
{
(100,): 3,
(101,): 0,
(102,): 5,
...
}
```

Where the keys are values and the values are the partition index in which they should be allowed. Building this mapping requires a full reduction of this column to a single dataframe (or we could split things up if we wanted to I guess, similar to split_out). Actually that could probably be a pandas DataFrame with a multi-index?.

Then we would need to broadcast that data out to all of the partitions again.

Contributor guide

Open the contributing guide

Research direction

Start at the df.drop_duplicates(subset=...) entry point and review how the current operation handles all columns and partitions. Define how subset values should be mapped to partitions, how the mapping is reduced and broadcast, and what tests are needed to show scalable subset deduplication is complete.

Written by the indexing model from the issue text.

Assessment

Tech stack
pandas, python
Domain
data, distributed-systems, performance
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.