Python 一次附加多个熊猫数据框
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/36526282/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Append multiple pandas data frames at once
提问by user3664020
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)
Let us say there are 5 pandas data frames t1
, t2
, t3
, t4
, t5
. How do I append them at once? Something equivalent of
假设有 5 个 Pandas 数据框t1
, t2
, t3
, t4
, t5
。我如何一次附加它们?相当于
df = rbind(t1,t2,t3,t4,t5)
采纳答案by tfv
Have you simply tried using a list as argument of append? Or am I missing anything?
您是否只是尝试使用列表作为 append 的参数?还是我错过了什么?
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