0

I'm looping through sheets in an excel file, doing a calculation, and then creating a DataFrame (only 1 column, 15 rows) from each. Each time I loop through a sheet from the excel file and create it's DataFrame, I would like to add that to a larger DataFrame.

sheet = 0 
peptides = []
for i in range (5):
    f = one_sheet(file,sheet,index)
    sheet = sheet + 1 
    peptides.append(f)

so i've created a list of the dataframes, and I tried:

    df_final = pd.concat([peptides], axis=1)

but I get an error- TypeError: cannot concatenate a non-NDFrame object

i've also tried something like:

sheet = 0 
peptides = []
df_final = pd.DataFrame(index=index)
for i in range (5):
    f = one_sheet(file,sheet,index)
    sheet = sheet + 1 
    peptides.append(f)
    df_final.add(f, axis=1)

which only returns

Empty DataFrame Columns: [] Index: [500, 250, 125, 63, 32, 16, 8, 4, 2, 1, 0.5, .25, .125, .0625, .03125]

Any suggestions?

Sarah Allen
  • 73
  • 3
  • 7

0 Answers0