【python求助】for循环,如何分别储存过程中的DataFrame

这个是我想实现的结果,每一个excel分别做没问题。

复制代码
df03 = pd.read_excel('03CP_IndStockCnsExpInd.xlsx')
df03.drop(index=[0, 1], inplace=True) ##删除行名为0,1的行

df04 = pd.read_excel('04CP_IndStockCnsExpInd.xlsx')
df04.drop(index=[0, 1], inplace=True) ##删除行名为0,1的行

# Let's concatenate both dataframes #1 and #2
investor_df_combined = pd.concat([df03, df04])
investor_df_combined
investor_df_combined.reset_index(drop = True)

(是excel表100w行放不下了,整合到一个DataFrame,表头是一模一样的)

学着用for 循环,主要问题是:

复制代码
DFs = []
for x in ['03CP_IndStockCnsExpInd.xlsx', '04CP_IndStockCnsExpInd.xlsx']:
    data_x_df = pd.read_excel(x)
    data_x_df.drop(index=[0, 1], inplace=True) ##删除行名为0,1的行
    DFs.append(data_x_df)
DFs

这样先建立空的df,for循环中用append,得到的结果每个excel还是分开的,没能合并

我想是不是DFs的创建不应该是list?

相关推荐
专注VB编程开发20年22 分钟前
javascript的类,ES6模块写法在VSCODE中智能提示
开发语言·javascript·vscode
郭庆汝5 小时前
pytorch、torchvision与python版本对应关系
人工智能·pytorch·python
黄雪超8 小时前
JVM——函数式语法糖:如何使用Function、Stream来编写函数式程序?
java·开发语言·jvm
ThetaarSofVenice8 小时前
对象的finalization机制Test
java·开发语言·jvm
思则变8 小时前
[Pytest] [Part 2]增加 log功能
开发语言·python·pytest
lijingguang8 小时前
在C#中根据URL下载文件并保存到本地,可以使用以下方法(推荐使用现代异步方式)
开发语言·c#
漫谈网络8 小时前
WebSocket 在前后端的完整使用流程
javascript·python·websocket
¥-oriented9 小时前
【C#中路径相关的概念】
开发语言·c#
CoderCodingNo9 小时前
【GESP】C++四级考试大纲知识点梳理, (7) 排序算法基本概念
开发语言·c++·排序算法
恋猫de小郭9 小时前
Meta 宣布加入 Kotlin 基金会,将为 Kotlin 和 Android 生态提供全新支持
android·开发语言·ios·kotlin