模糊匹配列,列表的正确名称
我有带有错别字的DataFrame列。
ID | Banknane |
---|---|
1 | 美国银行 |
2 | 美国 |
3 | JP MORG |
4 | JP MORGAN |
和我有一个带有银行名称的清单。
["Bank of America", "JPMorgan Chase]
我想在Levenshtein距离的帮助下,用列表的正确名称来检查并替换错误的钞票名称。
I have dataframe column with typos.
ID | Banknane |
---|---|
1 | Bank of America |
2 | bnk of America |
3 | Jp Morg |
4 | Jp Morgan |
And I have a list with the right names of the banks.
["Bank of America", "JPMorgan Chase]
I want to check and replace wrong banknames with the right names of the list with the help of levenshtein distance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一种使用Python标准库 fivflib 模块,这是一种简单的方法。提供计算三角洲的助手。
然后:
这样:
当然,您可以将Inner
比率
函数替换为任何其他更适合的序列匹配器。Here is one simple way to do it using Python standard library difflib module, which provides helpers for computing deltas.
And then:
So that:
Of course, you can replace the inner
ratio
function with any other more appropriated sequence matcher.