For a number. 1, you can specify skip_footer as described here ; or alternatively do
data = data.iloc[:-2]
after reading the data.
For a number. 2, you can:
from os.path import basename data.index = [basename(f)] * len(data)
Also, it might be better to place all the data frames in a list, and then concat them at the end; something like:
df = [] for f in ['c:\\file1.xls', 'c:\\ file2.xls']: data = pd.read_excel(f, 'Sheet1').iloc[:-2] data.index = [os.path.basename(f)] * len(data) df.append(data) df = pd.concat(df)
behzad.nouri
source share