欢迎您访问365答案网,请分享给你的朋友!
生活常识 学习资料

220228-Pandas保存Acc与Std并导出Excel

时间:2023-05-21

import numpy as npimport pandas as pd def save_acc_std_results(data_mean, data_std, methods, tasks): from styleframe import Styleframe data_stat = np.zeros_like(data_mean, dtype='object') m, n = data_mean.shape for r in range(m): for c in range(n): data_stat[r, c] = '{:.2f}n({:.2f})'.format(data_mean[r,c]*100, data_std[r,c]*100) data_df = pd.Dataframe(data_stat, index= methods, columns=tasks) print(data_df) Styleframe(data_df).to_excel('Result_demo666.xlsx', index=True).save()if __name__=='__main__': methods = ['M01', 'M02', 'M03'] tasks = ['T01', 'MT2', 'T03', 'T04'] num_repeat = 5 num_method = len(methods) num_task = len(tasks) data = np.random.randn(num_repeat,num_method,num_task) data_mean = data.mean(axis=0) data_std = data.std(axis=0) save_acc_std_results(data_mean, data_std, methods, tasks)

Copyright © 2016-2020 www.365daan.com All Rights Reserved. 365答案网 版权所有 备案号:

部分内容来自互联网,版权归原作者所有,如有冒犯请联系我们,我们将在三个工作时内妥善处理。