Pandas入门之十六:级联

已信任
Jupyter 服务器: 本地
Python 3: Not Started
[1]



import pandas as pd
import numpy as np



[2]




one = pd.DataFrame({
    'name':['alex','xm','xh','lc','ll'],
    'subject':['python','java','go','js','html'],
    'score':[88,79,68,96,66]
})
one
name    subject    score
0    alex    python    88
1    xm    java    79
2    xh    go    68
3    lc    js    96
4    ll    html    66
[4]



two = pd.DataFrame({
    'name':['xc','xm','xh','lc','ll'],
    'subject':['php','java','go','js','html'],
    'score':[89,79,68,96,66]
})
two
name    subject    score
0    xc    php    89
1    xm    java    79
2    xh    go    68
3    lc    js    96
4    ll    html    66
[6]



# 按行
pd.concat([one,two],ignore_index=True)
name    subject    score
0    xc    php    89
1    xm    java    79
2    xh    go    68
3    lc    js    96
4    ll    html    66
5    xc    php    89
6    xm    java    79
7    xh    go    68
8    lc    js    96
9    ll    html    66
[7]



# 按列
pd.concat([one,two],ignore_index=True,axis=1)
0    1    2    3    4    5
0    xc    php    89    xc    php    89
1    xm    java    79    xm    java    79
2    xh    go    68    xh    go    68
3    lc    js    96    lc    js    96
4    ll    html    66    ll    html    66
[-]

 

上一篇:nested exception is org.hibernate.exception.GenericJDBCException: Cannot open connection


下一篇:Firefox和Chrome拼性能,结果……