pandas.errors.MergeError: Passing ‘suffixes‘ which cause duplicate columns {‘状态_x‘} is not allowed.

1、错误原因。

使用merge()函数时,2个表中出现了重复列,原因是pandas2.0.0删除了以前版本可以默认将重复列转换成"状态_x","状态_y"的形式。(版本更换不兼容是真的坑啊!)

  • Enforced disallowing merge() to produce duplicated columns through the suffixes keyword and already existing columns (GH 22818)

2、修改方法,在merge函数中加入参数suffixes

pd.merge(df1,df2,how=left,left_index=True,right_index=True,suffixes=('_old','_new')

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值