pandas把多个excel合并的方法

import pandas as pd

df1.to_excel(aud,index=False)

只有先读取才能在合并

df 是上一个有的
    a = pd.read_excel(audio_kugou)
    df2 = pd.concat([df,a],axis=1)
    df2.to_excel('audio_hash',index=False)

dfs = []
for fn in ('1.xlsx', '2.xlsx', '3.xlsx', '4.xlsx'):
    dfs.append(pd.read_excel(fn))
# 将多个DataFrame合并为一个
df = pd.concat(dfs)
# 写入Excel文件,不包含索引数据
df.to_excel('result.xlsx', index=False)

猜你喜欢

转载自blog.csdn.net/king_26852/article/details/85064760