2

how to eliminate rown that have a word i don't want? I have this DataFrame:

index  price    description
0      15       Kit 10 Esponjas Para Cartuchos Jato De Tinta ...
1      15       Snap Fill Para Cartuchos Hp 60 61 122 901 21 ...
2      16       Clips Para Cartuchos Hp 21 22 60 74 75 92 93 ...

I'm trying to remove the rown with the word 'esponja'

i want a DataFrame like this:

index  price    description
    1      15       Snap Fill Para Cartuchos Hp 60 61 122 901 21 ...
    2      16       Clips Para Cartuchos Hp 21 22 60 74 75 92 93 ...

i'm newbe, i don't have any idea how to resolve that

timgeb
  • 64,821
  • 18
  • 95
  • 124

1 Answers1

4

Create a boolean mask by checking for strings that contain 'Esponjas', then index into your dataframe with the negated mask.

df[~df['description'].str.contains('Esponjas')]

If you are unsure what's going on, print out what

df['description']
df['description'].str.contains('Esponjas')
~df['description'].str.contains('Esponjas')

do on their own. If you want to perform the substring-check case-insensitively, use case=False as a keyword argument to str.contains.

timgeb
  • 64,821
  • 18
  • 95
  • 124