I want to filter a DataFrame
based on whether the value of one string column is a substring of the value in another string column.
According to this 2-year-old post this can be done using apply like so:
df = pd.DataFrame({'FNAME': ['Max', 'Tobi'], 'LNAME': ['Foo', 'Tobiwan']})
df.loc[ df.apply(lambda row: row.FNAME in row.LNAME, axis=1) ]
FNAME LNAME
1 Tobi Tobiwan
I was wondering if there is some built-in vectorized way of doing this?
Using
replace