What I am trying to do is:
Given a series with strings, to find all the indexes of the strings, that are substring of another main string, in a vectorize manner.
The Input:
series = pd.Series(['ab', 'abcd', 'bcc', 'abc'], name='text')
main_text = 'abcX'
# The series:
0 ab
1 abcd
2 bcc
3 abc
Name: text, dtype: object
The desired output:
0 ab
3 abc
Name: text, dtype: object
What I tried:
df_test = pd.DataFrame(series)
df_test['text2'] = main_text
df_test['text'].isin(df_test)
# And this of course won't work, since it check if the main string is a
# substring of the series strings:
series.str.contains(main_text, regex=True)
Thanks!