【发布时间】:2018-07-01 16:32:10
【问题描述】:
虽然我在record linkage python 文档中实现了这个代码示例:
import recordlinkage
from recordlinkage.datasets import load_febrl4
dfA, dfB = load_febrl4()
# Indexation step
indexer = recordlinkage.BlockIndex(on='given_name')
pairs = indexer.index(dfA, dfB)
# Comparison step
compare_cl = recordlinkage.Compare()
compare_cl.exact('given_name', 'given_name', label='given_name')
compare_cl.string('surname', 'surname', method='jarowinkler', threshold=0.85, label='surname')
compare_cl.exact('date_of_birth', 'date_of_birth', label='date_of_birth')
compare_cl.exact('suburb', 'suburb', label='suburb')
compare_cl.exact('state', 'state', label='state')
compare_cl.string('address_1', 'address_1', threshold=0.85, label='address_1')
features = compare_cl.compute(pairs, dfA, dfB)
# Classification step
matches = features[features.sum(axis=1) > 3]
print(len(matches))
我遇到以下错误:
Error: ValueError: Duplicated level name: "rec_id", assigned to level 1, is already used for level 0.
【问题讨论】:
-
代码运行没有错误,并在 Jupyter 上显示所需的输出
-
@NipunSampath 对于不使用 Jupyter 笔记本的人,您是否知道可能导致该错误的原因?
-
谢谢,它在 Jupyter notebook 上也对我有用。
-
我认为这与版本有关。虽然不确定
标签: python record-linkage