0
我剛剛拿起了python,我試圖使用模塊fuzzwuzzy與pandas一起協助匹配來自PLACEMENT和CREATIVE_NAME列的名稱。Python循環通過單個單元格和csv中的列
我已經想出瞭如何針對所有CREATE_NAME行測試PLACEMENT的第一行;但是,我無法弄清楚如何移動到PLACEMENT的下一行,並針對CREATIVE_NAME列進行測試。
該項目的最終目標是打印每個PLACEMENT值的最佳匹配以便進一步分析。
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
謝謝,代碼工作完美!非常感謝您的反饋。是的,每列大約有15,000行。我將需要找到一種方法來首先對數據進行分組。 5排花了近20分鐘。 –