As mentioned in the comments, one mistake you make is that you iterate over an empty list.
Here's how I would do it, using the example of having five identical Excel files that are added one by one.
(1) Import:
import os import pandas as pd
(2) File List:
path = os.getcwd() files = os.listdir(path) files
Output:
['.DS_Store', '.ipynb_checkpoints', '.localized', 'Screen Shot 2013-12-28 at 7.15.45 PM.png', 'test1 2.xls', 'test1 3.xls', 'test1 4.xls', 'test1 5.xls', 'test1.xls', 'Untitled0.ipynb', 'Werewolf Modelling', '~$Random Numbers.xlsx']
(3) Select the "xls" files:
files_xls = [f for f in files if f[-3:] == 'xls'] files_xls
Output:
['test1 2.xls', 'test1 3.xls', 'test1 4.xls', 'test1 5.xls', 'test1.xls']
(4) Initialize an empty framework:
df = pd.DataFrame()
(5) List the list of files to add to an empty framework:
for f in files_xls: data = pd.read_excel(f, 'Sheet1') df = df.append(data)
(6) Enjoy the new data framework. :-)
df
Output:
Result Sample 0 a 1 1 b 2 2 c 3 3 d 4 4 e 5 5 f 6 6 g 7 7 h 8 8 i 9 9 j 10 0 a 1 1 b 2 2 c 3 3 d 4 4 e 5 5 f 6 6 g 7 7 h 8 8 i 9 9 j 10 0 a 1 1 b 2 2 c 3 3 d 4 4 e 5 5 f 6 6 g 7 7 h 8 8 i 9 9 j 10 0 a 1 1 b 2 2 c 3 3 d 4 4 e 5 5 f 6 6 g 7 7 h 8 8 i 9 9 j 10 0 a 1 1 b 2 2 c 3 3 d 4 4 e 5 5 f 6 6 g 7 7 h 8 8 i 9 9 j 10