我有几个数据框(形状相同),我想附加创建一个更大的数据框。 每个数据框的类型都是一样的。
C-Mastersheet.xlsx <class 'pandas.core.frame.DataFrame'>
D-Mastersheet.xlsx <class 'pandas.core.frame.DataFrame'>
L-Mastersheet.xlsx <class 'pandas.core.frame.DataFrame'>
并且看起来像。
C-Mastersheet.xlsx
First Name Last name Dept Location Status Concat
0 Jo Jones Accounts Bristol Current JonesJo
1 Sid Smith Sales Hull New SmithSid
D-Mastersheet.xlsx
First Name Last name Dept Location Status Concat
0 Phil Evans Production Hull Current EvansPhil
1 Sarah Heath Marketing Bristol Current HeathSarah
2 Jane Hill Accounts Bristol Current HillJane
3 Amy Cooper Sales Hull Current CooperAmy
L-Mastersheet.xlsx
First Name Last name Dept Location Status Concat
0 Marcus Price Operations Hull Current PriceMarcus
1 Andrew King Design Bristol Current KingAndrew
2 Emma Lane Marketing Bristol Current LaneEmma
3 Brian Deen Accounts Bristol Current DeenBrian
4 Steve Jacks Design Bristol Current JacksSteve
我正试图返回输出。
First Name Last name Dept Location Status Concat
0 Jo Jones Accounts Bristol Current JonesJo
1 Sid Smith Sales Hull New SmithSid
2 Phil Evans Production Hull Current EvansPhil
3 Sarah Heath Marketing Bristol Current HeathSarah
4 Jane Hill Accounts Bristol Current HillJane
5 Amy Cooper Sales Hull Current CooperAmy
6 Marcus Price Operations Hull Current PriceMarcus
7 Andrew King Design Bristol Current KingAndrew
8 Emma Lane Marketing Bristol Current LaneEmma
9 Brian Deen Accounts Bristol Current DeenBrian
10 Steve Jacks Design Bristol Current JacksSteve
我试图用下面的代码来做这件事,它在一个目录周围循环。
ConsolidatedData = pd.DataFrame
for i in os.listdir(os.chdir(returnsfolder)):
if i.endswith(".xlsx"):
rawFilePath = returnsfolder +'\\'+ i
DeptReturn = openRawDeptReturn(rawFilePath)
ConsolidatedData = ConsolidatedData.append(DeptReturn,ignore_index=True)
然而,我得到了以下类型的错误。
TypeError: append() missing 1 required positional argument: 'other'
我以前没有遇到过这种情况。