gpt4 book ai didi

python - 创建和附加数据框

转载 作者:行者123 更新时间:2023-12-01 01:31:31 25 4
gpt4 key购买 nike

我有一个函数可以给我一个数据框 olddataframe作为循环中的输出,我想将它们组合成一个数据帧,如 newdataframe通过附加,我尝试了下面的代码

newdataframe=pd.DataFrame
newdataframe.append(olddataframe,ignore_index=False)

它抛出如下错误

TypeError: append() missing 1 required positional argument: 'other'

需要采取什么措施来解决这个问题

最佳答案

我建议创建DataFrame列表然后concat如果性能很重要,则仅一次:

dfs = []
for olddataframe in data:
#data processing
dfs.append(olddataframe)

newdataframe = pd.concat(dfs, ignore_index=False)

关于python - 创建和附加数据框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52814937/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com