源代码
import pandas as pd
df1= pd.read_excel('C:/Users/Kinglake/Desktop/1.xlsx')
df2 = pd.read_excel('C:/Users/Kinglake/Desktop/2.xlsx')
df3 = pd.read_csv('C:/Users/Kinglake/Desktop/3.csv')
pd.concat([df1,df2,df3,df4,df5,df6],join='outer',ignore_index=True).fillna(0).to_excel("C:/Users/Kinglake/Desktop/output.xlsx")
节省内存的尝试
import pandas as pd
df1= pd.read_csv('/home/ubuntu/Downloads/Thecountry-eachlevel/Thecountry-level-6/The-country01-level-6.csv')
df2 = pd.read_csv('/home/ubuntu/Downloads/Thecountry-eachlevel/Thecountry-level-6/The-country02-level-6.csv')
temp1=pd.concat([df1,df2],join='outer',ignore_index=True)
del df1,dl2
df3 = pd.read_csv('/home/ubuntu/Downloads/Thecountry-eachlevel/Thecountry-level-6/The-country03-level-6.csv')
df4 = pd.read_csv('/home/ubuntu/Downloads/Thecountry-eachlevel/Thecountry-level-6/Thecountry04-level-6.csv')
temp2=pd.concat([df3,df4],join='outer',ignore_index=True)
del df3,dl4
df5 = pd.read_csv('/home/ubuntu/Downloads/Thecountry-eachlevel/Thecountry-level-6/Thecountry05-level-6.csv')
df6 = pd.read_csv('/home/ubuntu/Downloads/Thecountry-eachlevel/Thecountry-level-6/Thecountry06-level-6.csv')
temp3=pd.concat([df5,df6],join='outer',ignore_index=True)
del df5,dl6
temp4=pd.concat([temp1,temp2],join='outer',ignore_index=True)
del temp1,temp2
pd.concat([temp3,temp4],join='outer',ignore_index=True).fillna(0).to_excel("/home/ubuntu/Downloads/Thecountry-eachlevel/Thecountry-level-6/output6.xlsx")
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!