I have the following dataframe:
g= pd.DataFrame({'A':[1,2,42,5,7],'B':[5,6,7,3,2]})
    A  B
0   1  5
1   2  6
2  42  7
3   5  3
4   7  2
am using the following list to filter the dataframe:
list_values = [5,7,1]
and get the following output using:
indexes = g[g['A'].isin(list_values)].index.values
output
array([0, 3, 4], dtype=int64)
How do I change the code so that indexes is the following?
array([3, 4, 0], dtype=int64)
Essentially, I am looking for a way to filter a DF with a list and return the original index values in the order of the filter list.
Thanks!
I looked at this but did not find what I was looking for: Select rows of pandas dataframe from list, in order of list
 
    