import pandas as pd import numpy as np df = pd.DataFrame({'A': [1, 2, 3, 4, 5], 'B': [1, 4, 2, 6, 5]}) # get the positions where values of columns A and B match mask = np.where(df['A'] == df['B'])[0] matches = df.index[mask] print(matches)