Skip to content
Advertisement

Retrieve all occurrencies from selected attributes to separate column in pandas

want to extract color from the product descriptions. I tried to use NER but it was nt successful. Now I am trying to define a list and match it with description.

I have data in dataframe column like this:

JavaScript

I defined also the list of colors

JavaScript

What I did was to create a matcher

JavaScript

And I applied it to the df

JavaScript

The result is horrible too. I get result:

JavaScript

How can I retrieve all the matches into list and store them in separate column in pandas? Expected output:

JavaScript

How can I prevent having red as match where there is no red?

I thought I would use

JavaScript

to retrieve the data how I want them but also that doesnt help me…

Lost. Thanks for help!

Advertisement

Answer

Jezreel’s first answer is very good! however when using

JavaScript

it will always find red when words such as “Tampered ” and such I suggest an easy quick fix (which is not the most robust one) but

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement