共同价值,交叉点,文本数据,数据框架,熊猫

发布于 2025-01-22 11:32:49 字数 832 浏览 3 评论 0原文

我在Python代码中有一个数据框。我想从数据框架中提取公共阀,并将这些共同值保存在下一列中。我有一列名称文章,并将此列与单词进行比较,并将每个值保存到Python DataFrame中的下一列。

“

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

给我错误

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文