how to get the positions where values of two columns match 3f

Solutions on MaxInterview for how to get the positions where values of two columns match 3f by the best coders in the world

showing results for - "how to get the positions where values of two columns match 3f"
Carlos
17 May 2019
1import pandas as pd 
2import numpy as np 
3
4#1
5df.index[df['BoolCol'] == True].tolist()
6
7#2
8df.index[df['BoolCol']].tolist()
9
10#ex : 
11df = pd.DataFrame({'fruit1': np.random.choice(['apple', 'orange', 'banana'], 10),
12                    'fruit2': np.random.choice(['apple', 'orange', 'banana'], 10)})
13
14out = df.index[df.fruit1 == df.fruit2].tolist()