object - ValueError:您正在尝试合并 object 和 int64 列。如果你想继续,你应该使用 pd.concat
问题描述
您好我正在尝试执行模糊匹配器代码,但出现以下错误:
ValueError: You are trying to merge on object and int64 columns. If you wish to proceed you should use pd.concat
即使我要匹配的列的类型相同,也会发生这种情况,有问题的变量位于P009_01, P009_2, P009_03
左侧和apellido1, apellido2, names
右侧数据框上。
df1.dtypes
P001 int64
P002 int64
P003 int64
P017 object
P020_01 float64
WP109 int64
WP114 int64
WP115 int64
P009_01 object
P009_02 object
P009_03 object
tenure_security float64
inv2 object
P086_01 object
inv7 object
inv11 object
P121 float64
c_ubigeo int64
dtype: object
另一个:
df2.dtypes
COD_PREDIO object
AREA_HA float64
DEPARTAMENTO object
PREDIO object
NUM_PREDIO int64
ID_DIST int64
ID_PROV int64
P001 int64
P009_01 object
P009_02 object
P009_03 object
P002 int64
P003 int64
p_ubigeo int64
ubigeo int64
apellido1 object
apellido2 object
nombres object
PETT_0 int64
dtype: object
需要匹配的变量来自同一类型,所以我看不出问题出在哪里,有人能发现吗?这是代码:
matched_results = fuzzymatcher.fuzzy_left_join(df1,
df2,
left_on,
right_on,
left_id_col = 'P003',
right_id_col = 'ID_DIST')
我错过了什么吗?提前致谢!
解决方案
推荐阅读
- java - Spring Data CosmosTemplate 使用系统函数创建查询
- rust - 评估借来的布尔值
- django-rest-framework - 如何使用 Django Rest 批量更新子对象?
- if-statement - 为什么我的 If else 语句不起作用?
- node.js - 带有 KnexJs 的 AWS Lambda(node12.x) 仅在第一次运行时调用并在随后的时间失败
- c++ - 双指针如何从单个指针中获取值
- sql - 如何用罗马数字显示当前年份?
- powershell - 无法使用 cd 继续前进
- visual-studio-code - VS 代码,julia linter 不起作用(在 mac 上)
- ios - 隐藏时如何删除“PTCardTabBar”后面的空白?