Anisha Alluru
Anisha Alluru

Reputation: 45

Masking dataframe by substring in column

I have a column in my dataframe called tags

abc
123489
abcdefg
qwerabcas
sid abc 239
8273491

Please give me a way for me to be able to display the rows where abc is present so the output will have rows

abc
abcdefg
qwerabcas
sid abc 239

Upvotes: 1

Views: 862

Answers (1)

Vishnudev Krishnadas
Vishnudev Krishnadas

Reputation: 10960

Use pandas.Series.str.contains

df[df['tags'].str.contains('abc')]

Upvotes: 4

Related Questions