用pandas将多个excel文件合并成一个大表

 1 import os
 2 import pandas as pd
 3 path = r'C:\Users\Administrator\Desktop\合并'
 4 df_list =[]
 5 for filename in os.listdir(path):
 6     if filename[0] == '~':
 7         continue
 8     a = os.path.join(path, filename)
 9     df = pd.read_csv(a)
10     df_list.append(df)
11 ans = pd.concat(df_list)
12 ans.to_excel("全部债券.xlsx")

 

posted @ 2022-03-08 16:53  timeaftertime  阅读(314)  评论(0编辑  收藏  举报