Pandas version checks
-
[x] I have checked that this issue has not already been reported.
-
[x] I have confirmed this bug exists on the latest version of pandas.
-
[x] I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
import pandas as pd
indA=pd.Index([1,3,5,7,9])
indB=pd.Index([2,3,5,7,11])
indA & indB
Issue Description
the output i am getting is : Index([0, 3, 5, 7, 9], dtype='int64')
Expected Behavior
but after intersection, i should get the output: Index([3, 5, 7], dtype='int64')
Installed Versions
Replace this line with the output of pd.show_versions()
Comment From: jbrockmendel
&
stopped being an intersection a long time ago. It is the __and__
operator, the same as for Series/DataFrame. Try indA.intersection(indB)
.