Skip to content

ENH: Add first_inverted and last_inverted options to keep in DataFrame.duplicated #60394

Open
@tommycarstensen

Description

@tommycarstensen

Feature Type

  • Adding new functionality to pandas

  • Changing existing functionality in pandas

  • Removing existing functionality in pandas

Problem Description

I suggest adding options first_inverted and last_inverted as keep options to function pandas.DataFrame.duplicated. Below an example of how it would work and what it would return.

df = pd.DataFrame({
'brand': ['Yum Yum', 'Yum Yum', 'Yum Yum', 'Indomie', 'Indomie', 'Indomie'],
'style': ['cup', 'cup', 'cup', 'cup', 'pack', 'pack'],
'rating': [4, 4, 4, 3.5, 15, 5],
})

df.duplicated(keep='first_inverted')

0 True
1 False
2 False
3 False
4 False
5 False
dtype: bool

Feature Description

.

Alternative Solutions

.

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Closing CandidateMay be closeable, needs more eyeballsEnhancementNeeds DiscussionRequires discussion from core team before further actionduplicatedduplicated, drop_duplicates

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions