import pandas as pd 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 = df['A'] == df['B'] matches = df.loc[mask].index print(matches)