Given this pandas.core.frame.DataFrame sample:
col
0 2 0
0 1
3 1
I would like to get those indexes where col is 1:
df[df['col']==1]
The expected result would be a vector (0,3).
You can use NumPy to create an array of indices, and then filter for the second index:
import numpy as np
df = pd.DataFrame({'col': [0, 1, 1]},
index=pd.MultiIndex.from_tuples([(0, 2), (0, 0), (0, 3)]))
# col
# 0 2 0
# 0 1
# 3 1
idx = np.array(df[df['col'] == 1].index.tolist())
# array([[0, 0],
# [0, 3]])
res = idx[:, 1]
# array([0, 3])