Skip to content
Advertisement

Method type inside a column pandas

I have the following data frame

JavaScript

I need to iterate over the product to extract the unique values.
The problem is that when I tried to iterate over the column product:

JavaScript

The following error is shown: “‘method’ object is not iterable”.
To extract the product from the sentences I have used the code (using str.findall to retrieve the exact match from dictionary) which does not give any error when I apply on other examples.
Any suggestion on how to solve the problem? So that I can iterate over the column and lists?

Advertisement

Answer

In pandas exist function DataFrame.product, so selecting c.product raise error.

If need unique values in list use:

JavaScript

If need iteration by multiple columns use zip:

JavaScript

And for unique lists use sets:

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