Skip to content

Index.intersection bug? #8362

Closed
Closed
@tom-alcorn

Description

@tom-alcorn

I ran into an odd behaviour when taking the intersection of two Indexes. Specifically,

left = pd.Index(['A','B','A','C'])
right = pd.Index(['B','D'])
left.intersection(right)

returns

Index(['B', 'C'], dtype='object')

However, I would expect this to return

Index(['B'], dtype='object')

If Index(['B', 'C'], dtype='object') is the intended behaviour, can someone explain the rationale behind it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugIndexingRelated to indexing on series/frames, not to indexes themselves

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions