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

前端 未结 10 2218
有刺的猬
有刺的猬 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:11

    This error also happens if a column specified in the aggregation function dict does not exist in the dataframe:

    In [190]: group = pd.DataFrame([[1, 2]], columns=['A', 'B']).groupby('A')
    In [195]: group.agg({'B': 'mean'})
    Out[195]: 
       B
    A   
    1  2
    
    In [196]: group.agg({'B': 'mean', 'non-existing-column': 'mean'})
    ...
    SpecificationError: nested renamer is not supported
    
    

提交回复
热议问题