I need to extract all rows from the Results data frame such that Results[‘Class’] is in Results[Path_x’]
(In the specific case, it should only return me the second-to-last line because Results[‘Class’] is totally contained in Results[‘Path_x’] in the penultimate case)
I tried the following line of code:
However, that line always generates an empty data frame.
You can do
mask = results.apply(lambda x: ['Class'] in results['Path_x'], axis=1) results= results.loc[mask, :]