python中使用pd从多个workbooks中read_excel时再concat时,read_excel参数sheet_name=None和sheet_name得到的数据不同

1、我想从两个excel的workbook(分别是‘余额表2021’,‘余额表2020‘’)中取两个worksheet(名字均为‘原始数据’)进行concat合并,‘余额表2021’数据如下:

img


‘余额表2020’数据如下:

img

具体的代码如下:
import pandas as pd
import glob
import os
import sys
input_path = sys.argv[1]
output_file = sys.argv[2]
all_workbooks = glob.glob(os.path.join(input_path,'.xls'))
data_frames = []
for workbook in all_workbooks:
all_worksheets = pd.read_excel(workbook, sheet_name=None, index_col=None)
for worksheet_name, data in all_worksheets.items():
print('#1:{}'.format(data))
data_frames.append(data)
all_data_concatenated = pd.concat(data_frames, axis=0, ignore_index=True)
writer = pd.ExcelWriter(output_file)
all_data_concatenated.to_excel(writer, sheet_name='all_data_all_workbooks', index=False)
writer.save()

当all_worksheets = pd.read_excel(workbook, sheet_name=None, index_col=None)中的sheet_name=None时, for worksheet_name, data in all_worksheets.items()中输出的data为整个sheet,,为正确的目标数据,如下:

img


concat后的all_data_concatenated为想要的目标数据,具体如下:

img


但问题是:当all_worksheets = pd.read_excel(workbook, sheet_name=None, index_col=None)中的sheet_name=‘原始数据’时, for worksheet_name, data in all_worksheets.items()中输出的data为整个sheet中各列的series,具体如下:

img

,导致我无法通过concat(不管是axis=0或1)达到想要的结果,

img

我想要达到的结果:怎么样在指定sheet_name的同时,concat后的结果能和sheet_name=None一样。指定sheet名字和不指定名字有啥区别??