Pandas pd.merge()上的Keyerror
我正在尝试合并列“id”上的两个数据帧(“信用”和“信息”) 我的代码是:Pandas pd.merge()上的Keyerror,pandas,merge,keyerror,Pandas,Merge,Keyerror,我正在尝试合并列“id”上的两个数据帧(“信用”和“信息”) 我的代码是: c.execute('SELECT * FROM "credit"') credit=c.fetchall() credit=pd.DataFrame(credit) c.execute('SELECT * FROM "info"') info=c.fetchall() movies_df=pd.DataFrame(info) movies_df_merge=pd.merge(credit, movies_df, on=
c.execute('SELECT * FROM "credit"')
credit=c.fetchall()
credit=pd.DataFrame(credit)
c.execute('SELECT * FROM "info"')
info=c.fetchall()
movies_df=pd.DataFrame(info)
movies_df_merge=pd.merge(credit, movies_df, on='id')
表中的两个id列类型都是('credit'和'info')整数,但我不确定为什么我总是在'id'上得到一个键错误
我也尝试过:
movies_df_merge=movies_df.merge(credit, on='id')
读取两个数据帧的方式与此无关 只需打印两个数据帧(如果记录数量很大,则会 足够打印(打印头(df))) 然后看看他们。特别检查两个数据帧是否都包含 id列。也许其中一个是ID,而另一个是ID? 名称的大小写在这里很重要 还要检查两个数据帧中的id列是否为“正常”列
(不是索引的一部分)。完整键错误消息是什么?