'Common values, intersection, text data, data frame, pandas

I have a dataframe in python code. I want to extract the common valves from dataframe and save these common values in next column. I have a column name articles and compare this column with words and save each values to the next column in python dataframe.

image

frame1['C'] = [len(set(article).intersection(words)) for article, words in zip(frame1.article, frame1.words)]

gives me error

TypeError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_17260/4070584663.py in <module>
----> 1 frame1['C'] = [len(set(article).intersection(words)) for article, words in zip(frame1.article, frame1.words)]

~\AppData\Local\Temp/ipykernel_17260/4070584663.py in <listcomp>(.0)
----> 1 frame1['C'] = [len(set(article).intersection(words)) for article, words in zip(frame1.article, frame1.words)]

TypeError: 'float' object is not iterable


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source