Reputation: 257
In other words, I want to do the reverse of df.str.contains(somestring)
. I want something like somestring.contained_in(df.column)
that still returns a series.
Say I have a string abjk
and I have a dataframe
index letter
0 a
1 b
2 c
... ...
25 z
Then it should return rows 0, 1, 9, 10 as True
. This feels like something that should exist, but I can't seem to find it. Apologies in advance if this is a duplicate.
Upvotes: 0
Views: 36
Reputation: 2417
You might just do :
[l in 'abjk' for l in df.letter]
If you want later to return the rows, you could just use numpy.where
import numpy as np
rows, = np.where([l in 'abjk' for l in df.letter])
Upvotes: 1