【发布时间】:2020-08-12 18:30:48
【问题描述】:
我正在尝试确定 pandas 数据框中两列的相似性:
Text1 All
Performance results achieved by the approaches submitted to this Challenge. The six top approaches and three others outperform the strong baseline.
Accuracy is one of the basic principles of perfectionist. Where am I?
我想将'Performance results ... ' 与'The six...' 和'Accuracy is one...' 与'Where am I?' 进行比较。
第一行应该是两列之间的相似度较高,因为它包含一些单词;第二个应该等于 0,因为两列之间没有共同的单词。
比较我使用SequenceMatcher 的两列如下:
from difflib import SequenceMatcher
ratio = SequenceMatcher(None, df.Text1, df.All).ratio()
但使用df.Text1, df.All似乎是错误的。
你能告诉我为什么吗?
【问题讨论】:
标签: python pandas nlp sequencematcher