【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?

相关推荐
iAm_Ike4 小时前
Go 中自定义类型与基础类型间的显式类型转换详解
jvm·数据库·python
iuvtsrt4 小时前
Golang怎么实现方法集与接口的匹配_Golang如何理解值类型和指针类型实现接口的区别【详解】
jvm·数据库·python
chao1898445 小时前
基于 SPEA2 的多目标优化算法 MATLAB 实现
开发语言·算法·matlab
赏金术士5 小时前
Kotlin 习题集 · 高级篇
android·开发语言·kotlin
旦莫5 小时前
AI驱动的纯视觉自动化测试:知识库里应该积累什么知识内容
人工智能·python·测试开发·pytest·ai测试
楼兰公子6 小时前
buildroot 在编译rust时裁剪平台类型数量的方法
开发语言·后端·rust
知识领航员6 小时前
蘑兔AI音乐深度实测:功能拆解、实测表现与适用场景
java·c语言·c++·人工智能·python·算法·github
吴声子夜歌6 小时前
Go——并发编程
开发语言·后端·golang
ooseabiscuit7 小时前
Laravel4.x:现代PHP框架的奠基之作
java·开发语言·php
c1s2d3n4cs7 小时前
Qt模仿nlohmann::json进行序列化和反序列化
开发语言·qt·json