Solution for SpecificationError: nested renamer is not supported while agg() along with groupby()

前端 未结 10 2207
有刺的猬
有刺的猬 2020-12-15 21:23
def stack_plot(data, xtick, col2=\'project_is_approved\', col3=\'total\'):
    ind = np.arange(data.shape[0])

    plt.figure(figsize=(20,5))
    p1 = plt.bar(ind, d         


        
10条回答
  •  温柔的废话
    2020-12-15 22:09

    Do you get the same error if you change

    temp['total'] = pd.DataFrame(project_data.groupby(col1)[col2].agg({'total':'count'})).reset_index()['total']
    

    to

    temp['total'] = project_data.groupby(col1)[col2].agg(total=('total','count')).reset_index()['total']
    

提交回复
热议问题