【发布时间】:2021-11-07 04:36:48
【问题描述】:
我有那个代码:
def show_files(upload_files):
tempDF = pd.DataFrame()
tempDF2 = pd.DataFrame()
for file in upload_files:
file = file.name
if file.startswith('L'):
Table = Dbf5(file)
DF1 = Table.to_dataframe()
tempDF = tempDF.append(DF1, sort=False)
elif file.startswith('M'):
Table = Dbf5(file)
DF2 = Table.to_dataframe()
tempDF2 = tempDF2.append(DF2, sort=False)
print(f"final 2 - {tempDF2}")
return [tempDF, tempDF2]
Upload_files 它是一个带有文件名的列表。示例:
["M22.dbf", "M31.dfb", "L22.dfb"]
所有 dbf 都成功加载为 DF。我调试了它。所以DF1 = Table.to_dataframe() 工作正常。但是函数只从最后加载的文件中返回 DF...
例如:
1. Load M22 (500rows)
2. Put in TEMP_DF2 (temp_df2 = 500rows)
3. Load M31 (266rows)
4. Put in TEMP_DF2 with append(temp_DF2 = 266 rows, excepted 766)
我不知道为什么?我没有注意到错误。
【问题讨论】: