赞
踩
- # index=0,忽略索引;header=0,忽略表头;mode='a',可追加
- df.to_csv(data_output_path, index=0, header=0, sep='\t', float_format='%.4f', mode='a', encoding='gbk')
- # columns可以指定要保存的列
- df.to_csv(data_output_path, columns=['score'])
- df[['uid', 'score']].to_csv(data_output_path, index=None)
- df = pd.DataFrame([[app_name, cnt] for app_name, cnt in temp_dict.items()])
- df.columns = ['app_name', 'cnt']
- df = df.sort_values(by=['cnt'], ascending=[False])
- df.to_csv(output_file, index=None)
- data.to_excel(data_output_path, index=False)
- # 或:多个sheet页面
- # 生成一个excelWriter
- writer = pd.ExcelWriter('./tmpData/conclusion.xlsx')
- result_df.to_excel(writer, sheet_name='sheet_1', header=name_list, index=False)
- writer.save()
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。