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

相关推荐
databook14 小时前
Manim实现闪光轨迹特效
后端·python·动效
Juchecar15 小时前
解惑:NumPy 中 ndarray.ndim 到底是什么?
python
用户83562907805115 小时前
Python 删除 Excel 工作表中的空白行列
后端·python
Json_15 小时前
使用python-fastApi框架开发一个学校宿舍管理系统-前后端分离项目
后端·python·fastapi
数据智能老司机1 天前
精通 Python 设计模式——分布式系统模式
python·设计模式·架构
数据智能老司机1 天前
精通 Python 设计模式——并发与异步模式
python·设计模式·编程语言
数据智能老司机1 天前
精通 Python 设计模式——测试模式
python·设计模式·架构
数据智能老司机1 天前
精通 Python 设计模式——性能模式
python·设计模式·架构
c8i1 天前
drf初步梳理
python·django
每日AI新事件1 天前
python的异步函数
python