I have a dataframe with millions of lines. I need to get the corresponding indexes of hundreds of thousands of elements that are present in the original dataframe.
I currently use this code:
df[df['processed_col'] == element.index[0]
to find the position of 'element' into the whole dataframe.
Instead of doing a loop which is very long, is there a way to take a list like element1, element2,..., elementN as input, which would return a list of corresponding indices:
df[df['processed_col'] == [element1, element2, ..., elementN].index[0]
df[df['processed_col'].isin([element1, element2,..., elementN])].index[0]df[df['processed_col'].isin(some_list)].index?index[0]will return the first index valueindex[0], if need all values, useindex...