Python函数似乎返回空序列

时间:2018-06-27 03:02:56

标签: python pandas function

我正在尝试运行以下功能,但由于某些原因,它无法正常工作...

def totals(name_df):
    name_df = df.loc[df['candidate_name'] == 'name_df']
    for i in name_df:
        name_sector = name_df.groupby(['sector_name']) 
        \ ['sector_total'].mean()
        name_industry = name_df.groupby(['industry_name']) 
        \ ['industry_total'].mean()
        name_contributor= name_df.groupby(['contributor_name']) 
        \ ['contributor_total'].mean()
        names = [name_sector, name_industry, name_contributor]

    return names

print(totals('Random Person Name'))

我收到以下回溯消息:

[Series([], Name: sector_total, dtype: float64), Series([], Name: 
industry_total, dtype: float64), Series([], Name: contributor_total, 
dtype: float64)]

任何帮助将不胜感激

0 个答案:

没有答案