Reputation: 87
Dataframe contain columns called "product_description" and "manufacturer". I need to remove all rows where 'product_description' has 'manufacturer' in it.
I tried this code:
df[~df.product_description.str.contains(df.manufacturer)]
and it gave me error
TypeError: 'Series' objects are mutable, thus they cannot be hashed
Is there any other way to do it?
Very much appreciate for any help!
Upvotes: 2
Views: 186
Reputation: 862591
If need test all values from column manufacturer
per each value of column product_description
use join
with |
for regex or
:
df[~df.product_description.str.contains('|'.join(data.manufacturer))]
Or if need test per rows:
df[df.apply(lambda x: x.product_description not in x.manufacturer, axis=1)]
Upvotes: 3