赞
踩
- # 1. 加载初始dataframe
- early_size = pd.read_excel(target_file,'early-bind',index_col=0)
-
- # 2. 组织新加入的列的数据
- late_size_avg = []
- for func_name in workflow_info[workflow_name]:
- late_size_avg.append(np.average(late_size[func_name].dropna()))
-
- # 3. 加入一列
- early_size['late-size'] = late_size_avg
-
- # 4. 加入一行
- early_size.loc['total'] = early_size.to_numpy().sum(axis=0) #各列数据相加
- early_size.loc['late/early'] = [early_size.loc['total'][-1]/early_size.loc['total'][0],np.nan,1]
-
- # 5. 修改各列的排不顺序,并另存为其他文件
- early_size[['early-size','late-size','early-time-budget']].to_excel(excel_writer=writer,sheet_name=str(slo))
插入一行https://stackoverflow.com/questions/24284342/insert-a-row-to-pandas-dataframehttps://stackoverflow.com/questions/38733477/whats-the-best-way-to-sum-all-values-in-a-pandas-dataframehttp://dataframe各列求和
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。