Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 合并数据帧的问题_Python 3.x_Pandas_Dataframe - Fatal编程技术网

Python 3.x 合并数据帧的问题

Python 3.x 合并数据帧的问题,python-3.x,pandas,dataframe,Python 3.x,Pandas,Dataframe,我正在尝试合并两个数据帧。我通过分组创建了这些数据帧 下面是我用来创建数据帧的代码的副本: subdomain_wt_mx = links_webtrends_mx[['SubDomain','Page']].groupby(['SubDomain']).agg(['count']) subdomain_aa_mx =Mexico[['SubDomain','Page URL']].groupby(['SubDomain']).agg(['count']) 当我尝试合并它们时,会出现以下错误

我正在尝试合并两个数据帧。我通过分组创建了这些数据帧

下面是我用来创建数据帧的代码的副本:

subdomain_wt_mx = links_webtrends_mx[['SubDomain','Page']].groupby(['SubDomain']).agg(['count'])

subdomain_aa_mx =Mexico[['SubDomain','Page URL']].groupby(['SubDomain']).agg(['count'])
当我尝试合并它们时,会出现以下错误:

Common_Domain_Mx = subdomain_wt_mx.merge(subdomain_aa_mx,on=['SubDomain'])
我得到一个:

关键错误

有人能建议如何解决这个问题吗?

使用

Common_Domain_Mx = subdomain_wt_mx.merge(subdomain_aa_mx,on = 'SubDomain')
使用


同样的问题。Get Key ERROR你能发布子域_wt_mx.columns和子域_aa_mx.columns的输出吗?我已经用代码更新了它。请查看它,看看您是否能找出错误所在分组后得到的数据帧是多索引的,因此您需要执行子域\u wt\u mx=links\u webtrends\u mx[['subdomain','Page']].groupby(['subdomain']).agg(['count']).reset\u index()。如果在那之后它不起作用,pl会在重置索引名称问题后发布链接\u webtrends\u mx.head()。Get Key ERROR你能发布子域_wt_mx.columns和子域_aa_mx.columns的输出吗?我已经用代码更新了它。请查看它,看看您是否能找出错误所在分组后得到的数据帧是多索引的,因此您需要执行子域\u wt\u mx=links\u webtrends\u mx[['subdomain','Page']].groupby(['subdomain']).agg(['count']).reset\u index()。如果在这之后不起作用,pl在重置后发布链接\u webtrends\u mx.head()\u不可能重复的