I'm trying to locate the most recent rows within my Dataframe that contain the same values in two separate columns.
Presently, I am doing this slowly with looping, but I suspect there's a way to cleverly use the
apply method or some other vectorized function to do this faster.
My present code:
def enumerate_matching(df): a = list(df['A']) b = list(df['B']) matching =  for i in range(0, len(a)-1): for j in range(i+1, len(b)): if a[i] == b[j]: matching.append(i) matching.append(i+j) break return matching
Is there a faster method to do this?