Python 无法将DataFrame与类型为<;的实例合并;类别';pandas.core.groupby.DataFrameGroupBy'&燃气轮机;

Python 无法将DataFrame与类型为<;的实例合并;类别';pandas.core.groupby.DataFrameGroupBy'&燃气轮机;,python,pandas,dataframe,group-by,Python,Pandas,Dataframe,Group By,我试图解决这个错误 ValueError: can not merge DataFrame with instance of type <class 'pandas.core.groupby.DataFrameGroupBy'> 然后我运行了我想要的统计数据 resi_flats_nooutliers_bysector['updatedprice_calculated']. agg([np.mean,np.median,np.max,'count']) resi_all_noou

我试图解决这个错误

ValueError: can not merge DataFrame with instance of type <class 'pandas.core.groupby.DataFrameGroupBy'>
然后我运行了我想要的统计数据

resi_flats_nooutliers_bysector['updatedprice_calculated'].
agg([np.mean,np.median,np.max,'count'])

resi_all_nooutliers_bysector['updatedprice_calculated'].
agg([np.mean,np.median,np.max,'count'])
然后我试着合并为

df_resi_nooutliers_bysector = pd.merge(resi_all_nooutliers_bysector, 
                                       resi_flats_nooutliers_bysector,
                                       on=['postcode_sector'],how='left', 
                                       suffixes=('_allprop', '_flats'))

获取标题中的错误对我来说很有效,将agg输出保存到一个数据框中,确保索引位于原始索引上(列
邮政编码\u扇区

然后使用索引进行连接

merge_test = df2.merge(df1, left_index=True, right_index=True,suffixes=
('_allprop', '_flats'))
merge_test.head(10)`

缺少
resi\u all\u noutliers\u bysector
resi\u noutliers\u bysector
之间的间隙。关于
reset\u index
的错误:尝试无参数调用它。已编辑但存在差距,仍然得到相同的问题基本信息仍然滞后。您能否提供samplke数据(特别是w.r.t列(每个帧的列就足够了)。这可能有助于人们解决您的问题并理解错误,顺便说一句,这是非常清楚的:您不能将分组对象与非分组数据帧联接。但是,如果您仅将函数应用于组,它将再次成为数据帧,并且可以进行联接!添加了表,非常感谢任何帮助,这是python
res的新功能i\u flats\u nooutliers\u bysector
未定义!您的问题未定义明确。在您的最后一步中,您可能需要在左表中的索引和右表中的“postcode\u sector”上进行连接。请对您的问题进行清晰的简短描述,提供原始数据的一小部分,展示您已尝试的内容,并提供预期的输出。很好,减少问题通常会有帮助:)很高兴你自己找到了答案。
df1 = resi_flats_nooutliers_bysector['updatedprice_calculated'].\
agg([np.mean,np.median,np.max,'count'],as_index=False)

df2 = resi_all_nooutliers_bysector['updatedprice_calculated'].\
agg([np.mean,np.median,np.max,'count'],as_index=False)
type (resi_flats_nooutliers_bysector)
df1.head(10)
merge_test = df2.merge(df1, left_index=True, right_index=True,suffixes=
('_allprop', '_flats'))
merge_test.head(10)`