分组统计

input_name=r'D:\004 code\python\001pandas\tmp.xlsx'
data=pd.read_excel(input_name)
data.dropna(how='all')

flag=data['ap'].isna().values
for i in range(len(data)): ###填充空缺单元格,找出空缺的单位格,使用前一行的值填充该单元格
if flag[i]:
data.iloc[i,1]=data.iloc[i-1]

data_ok=data[['project','key','name']]
data_ok
data_group=data_ok.groupby(['project','key']).agg(' '.join)
data_group

posted @ 2021-07-06 21:32  oceaning  阅读(52)  评论(0编辑  收藏  举报