Skip to content

API: Index should support __inverse__ ops #8875

Closed
@sinhrks

Description

@sinhrks

Related to #7979

Because Index is no more the subclass of np.array, Index.duplicated returns Index with dtype=object. And Index don't accepts logical not.

idx = pd.Index([1, 2, 1, 3])

idx.duplicated()
# Index([False, False, True, False], dtype='object')

~idx.duplicated()
# TypeError: bad operand type for unary ~: 'Index'

As a result, it is impossible to drop data which have duplicated index using expression like df[~df.index.duplicated()]. This expression was worked at the timing of #7979.

Does Index.duplicated should return np.array with dtype=bool? Or Index should accept logical not?

Metadata

Metadata

Assignees

Labels

EnhancementIndexRelated to the Index class or subclasses

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions