【发布时间】:2020-04-24 12:43:57
【问题描述】:
可能重复pandas - Merging on string columns not working (bug?)
尝试合并以下两个数据帧时,我收到了有趣的消息。有谁知道发生了什么?删除 E 可以修复错误。
newvi = pd.DataFrame({'a':['E1000305', 'E1000505', 'E1001071', 'E99836', 'E1003822']})
newsm = pd.DataFrame({'a':['E1000305', 'E1000305', 'E1000305', 'E1000305', 'E1000305']})
newvi.a
#0 E1000305
#1 E1000505
#2 E1001071
#3 E99836
#4 E1003822
#Name: a, dtype: object
newsm.a
#0 E1000305
#1 E1000305
#2 E1000305
#3 E1000305
#4 E1000305
#Name: a, dtype: object
newvi.join(newsm, on='a')
#my computer
#ValueError: columns overlap but no suffix specified: Index([u'a'], dtype='object')
>>> pd.__version__
u'0.18.1'
#server
#ValueError: You are trying to merge on object and int64 columns. If you wish to proceed you should use pd.concat
>>> pd.__version__
'0.24.2'
【问题讨论】:
-
您希望连接的数据框是什么样的?