I'm looking for a way to check whether one string can be found in another string. str.contains
only takes a fixed string pattern as argument, I'd rather like to have an element-wise comparison between two string columns.
import pandas as pd
df = pd.DataFrame({'long': ['sometext', 'someothertext', 'evenmoretext'],
'short': ['some', 'other', 'stuff']})
# This fails:
df['short_in_long'] = df['long'].str.contains(df['short'])
Expected Output:
[True, True, False]