【发布时间】:2015-11-20 09:39:17
【问题描述】:
我刚刚学习了 python,我正在尝试将模块 fuzzwuzzy 与 pandas 一起使用来帮助匹配来自 PLACEMENT 和 CREATIVE_NAME 列的名称。
我已经弄清楚如何针对 CREATIVE_NAME 的所有行测试 PLACEMENT 的第一行;但是,我无法弄清楚如何移动到 PLACEMENT 的下一行并针对 CREATIVE_NAME 列进行测试。
我的项目最终目标是打印出每个展示位置值的最佳匹配项以供进一步分析。
df = pd.read_csv(filepath)
fp = df["PLACEMENT"]
tp = df["CREATIVE_NAME"]
score = 0
x=0
y=0
import csv
with open(filepath, 'r') as f:
reader = csv.DictReader(f)
for column in reader:
if score == 0:
score += fuzz.ratio(fp[x],tp[y])
if score > 95:
print "The score is %d"", We have a match!" %(score)
elif score > 70:
print "The score is %d"", We have a high likelihood of a match!" %(score)
elif score > 50:
print "The score is %d"", The match is not likely!" %(score)
else:
print "The score is only %d"", This is not a match!" %(score)
y += 1
score = 0
【问题讨论】:
标签: python pandas iterator iteration