首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Python中合并多个数据帧(超过2个)

在Python中合并多个数据帧(超过2个)
EN

Stack Overflow用户
提问于 2013-12-01 06:15:07
回答 1查看 486关注 0票数 0

我的源数据是数据帧的列表,如下所示:

代码语言:javascript
复制
In [101]: res
Out[101]: 
[  Round              Date               Home     Score             Away  
0     1  15/08/2009 20:45         Chelsea FC  2-1(1-1)        Hull City  
1     1  15/08/2009 23:00   Blackburn Rovers  0-2(0-1)  Manchester City  
2     1  15/08/2009 23:00             Wolves  0-2(0-1)  West Ham United  
3     1  15/08/2009 23:00   Bolton Wanderers  0-1(0-1)       Sunderland  
4     1  15/08/2009 23:00         Stoke City  2-0(2-0)          Burnley  
5     1  15/08/2009 23:00         Portsmouth  0-1(0-1)           Fulham  
6     1  15/08/2009 23:00        Aston Villa  0-2(0-1)   Wigan Athletic  
7     1  16/08/2009 01:30            Everton  1-6(0-3)          Arsenal  
8     1  16/08/2009 21:30  Manchester United  1-0(1-0)       Birmingham  
9     1  17/08/2009 00:00  Tottenham Hotspur  2-1(1-0)        Liverpool  ,
   Round              Date             Home     Score               Away  
0     2  19/08/2009 03:45       Sunderland  1-3(1-0)         Chelsea FC  
1     2  19/08/2009 03:45   Wigan Athletic  0-1(0-1)             Wolves  
2     2  20/08/2009 03:45          Burnley  1-0(1-0)  Manchester United  
3     2  20/08/2009 03:45        Hull City  1-5(1-3)  Tottenham Hotspur  
4     2  20/08/2009 03:45       Birmingham  1-0(0-0)         Portsmouth  
5     2  20/08/2009 04:00        Liverpool  4-0(2-0)         Stoke City  
6     2  05/11/2009 04:45  West Ham United  2-1(1-0)       Aston Villa   
7     2  26/11/2009 05:00           Fulham  3-0(1-0)   Blackburn Rovers  
8     2  21/01/2010 04:45          Arsenal  4-2(1-2)   Bolton Wanderers  
9     2  25/03/2010 04:45  Manchester City  0-2(0-1)            Everton  ,
   Round              Date             Home     Score               Away  
0     3  22/08/2009 23:00        Hull City  1-0(0-0)   Bolton Wanderers  
1     3  22/08/2009 23:00       Birmingham  0-0(0-0)         Stoke City  
2     3  22/08/2009 23:00       Sunderland  2-1(1-1)   Blackburn Rovers  
3     3  22/08/2009 23:00          Arsenal  4-1(2-1)         Portsmouth  
4     3  22/08/2009 23:00  Manchester City  1-0(1-0)             Wolves  
5     3  22/08/2009 23:00   Wigan Athletic  0-5(0-0)  Manchester United  
6     3  23/08/2009 21:30  West Ham United  1-2(0-0)  Tottenham Hotspur  
7     3  23/08/2009 23:00          Burnley  1-0(1-0)            Everton  
8     3  24/08/2009 00:00           Fulham  0-2(0-1)         Chelsea FC  
9     3  25/08/2009 04:00        Liverpool  1-3(0-2)        Aston Villa  ,
   Round              Date               Home     Score             Away  
0     4  29/08/2009 20:45         Chelsea FC  3-0(1-0)          Burnley  
1     4  29/08/2009 23:00         Stoke City  1-0(1-0)       Sunderland  
2     4  29/08/2009 23:00   Blackburn Rovers  0-0(0-0)  West Ham United  
3     4  29/08/2009 23:00             Wolves  1-1(0-1)        Hull City  
4     4  29/08/2009 23:00  Tottenham Hotspur  2-1(0-0)       Birmingham  
5     4  29/08/2009 23:00   Bolton Wanderers  2-3(1-1)        Liverpool  
6     4  30/08/2009 01:15  Manchester United  2-1(0-1)          Arsenal  
7     4  30/08/2009 21:30         Portsmouth  0-1(0-1)  Manchester City  
8     4  30/08/2009 23:00            Everton  2-1(0-0)   Wigan Athletic  
9     4  31/08/2009 00:00        Aston Villa  2-0(1-0)           Fulham  ]

我希望合并为运行在下面的代码,但是输出不是一个数据框架,而是对象的属性,我仍然对Python很新鲜。有人遮住我的灯吗?谢谢你,罗得。

代码语言:javascript
复制
res2 = res[0]
i = 1
while i < len(res):
     res2 = res2.append(res[i])
     i = i + 1
res2
print res2
Out[102]: 
<class 'pandas.core.frame.DataFrame'>
Int64Index: 380 entries, 0 to 9
Data columns (total 6 columns):
Round    380  non-null values
Date     380  non-null values
Home     380  non-null values
Score    380  non-null values
Away     380  non-null values
         380  non-null values
dtypes: object(6)
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-12-01 11:44:03

解出

代码语言:javascript
复制
pandas.set_option('display.height', 500)
pandas.set_option('display.max_rows', 500)
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20309318

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档