Reputation: 12320
I have a dataframe as below
username
NA
NA
NA
['Bob']
['']
['']
['Meril']
['Aston']
['Meril+Aston']
I need all the rows which has Bob, Meril and Aston or Meril+Aston or Bob+Aston....all combinations.
I tried
df.username.str.extract(r"\['Bob.*|['Meril.*|['Aston.*")
It not working
Upvotes: 0
Views: 36
Reputation:
Try this:
subset = df[df.username.astype('str').str.contains('Bob|Meril|Aston').fillna(False)]
Output:
>>> subset
username
3 ['Bob']
6 ['Meril']
7 ['Aston']
8 ['Meril+Aston']
Upvotes: 1