Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Appending pandas dataframes generated in a for loop

appended_data = []
for infile in glob.glob("*.xlsx"):
    data = pandas.read_excel(infile)
    # store DataFrame in list
    appended_data.append(data)
# see pd.concat documentation for more info
appended_data = pd.concat(appended_data)
# write DataFrame to an excel sheet 
appended_data.to_excel('appended.xlsx')
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Appending #pandas #dataframes #generated #loop
ADD COMMENT
Topic
Name
8+8 =