Index.intersection bug? · Issue #8362 · pandas-dev/pandas (original) (raw)
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?