将列表保存为excel文件的方法

两种将列表保存为excel文件的方法

第一种,先把要输出的列表转化成字典的形式

#第一种
ddd = {"timeseries_new" : timeseries_new, "outdoor_temp_new" : outdoor_temp_new, "indoor_temp_new" : indoor_temp_new, "indoor_humidity_new" : indoor_humidity_new, "indoor_CO2_new" : indoor_CO2_new, "window_new_01" : window_new_01
} #将列表a,b转换成字典
savedata = pd.DataFrame(ddd) #将字典转换成为数据框
savedata.to_excel(r'C:\Users\hao\Desktop\LogisticsRegression\处理后的数据\{}_window.xlsx'.format(excel_name))

在这里插入图片描述

#第二种
df = pd.DataFrame(timeseries_new, window_new_01)
df.to_excel(r'C:\Users\hao\Desktop\LogisticsRegression\处理后的数据\{}_window.xlsx'.format(excel_name))

在这里插入图片描述

第一种输出结果更好看,第二种应该可以改进,暂时不知道咋弄

猜你喜欢

转载自blog.csdn.net/shuyueliang1/article/details/85701857