pd.concat合并DataFram对象

利用pandas的concat函数进行拼接DataFrame。

常用参数:

1.合并DataFrame对象列表,如[df1, df2]

2.axis,沿着哪个轴进行合并。默认是axis=0,即沿着index进行拼接。

3.igonre_index,是否重构index,默认是False,不会重构。若为True,则会重构为0,1,2....的index。

下面是对ignore_index

a = pd.DataFrame([[1, 2, 3],[4, 5, 6]], index=['index1', 'index2'], columns=['clo1', 'col2', 'col3'])
        clo1  col2  col3
index1     1     2     3
index2     4     5     6
b = pd.DataFrame([['a', 'b', 'c'],['d', 'e', 'f']], index=['index3', 'index4'], columns=['clo1', 'col2', 'col3'])
       clo1 col2 col3
index3    a    b    c
index4    d    e    f
pd.concat([a, b],ignore_incex=False) 
       clo1 col2 col3
index1    1    2    3
index2    4    5    6
index3    a    b    c
index4    d    e    f
pd.concat([a, b],ignore_index=True)
  clo1 col2 col3
0    1    2    3
1    4    5    6
2    a    b    c
3    d    e    f




  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值