一次附加多个 pandas 数据帧 [英] Append multiple pandas data frames at once

查看:26
本文介绍了一次附加多个 pandas 数据帧的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试找到一种方法来一次附加多个熊猫数据帧,而不是使用一个一个地附加它们

I am trying to find some way of appending multiple pandas data frames at once rather than appending them one by one using

df.append(df)

假设有 5 个 pandas 数据帧 t1t2t3t4t5.我如何一次附加它们?相当于

Let us say there are 5 pandas data frames t1, t2, t3, t4, t5. How do I append them at once? Something equivalent of

df = rbind(t1,t2,t3,t4,t5)

推荐答案

您是否尝试过使用列表作为 append 的参数?还是我错过了什么?

Have you simply tried using a list as argument of append? Or am I missing anything?

import numpy as np
import pandas as pd

dates = np.asarray(pd.date_range('1/1/2000', periods=8))
df1 = pd.DataFrame(np.random.randn(8, 4), index=dates, columns=['A', 'B', 'C', 'D'])
df2 = df1.copy()
df3 = df1.copy()
df = df1.append([df2, df3])

print df

这篇关于一次附加多个 pandas 数据帧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆