Python3 pandas dataframe 数据拼接

    a = pd.DataFrame()
    a['A'] = [1, 2, 3, 4, 5]
    a['B'] = [6, 7, 8, 9, 0]
    b = a

    c = pd.concat((c, b), axis=1) # 拼接到列后,列增多
    print(c)
    print("*"*30)
    c = pd.concat((a, b), axis=0) # 拼接到行后,行增多
    print(c)


 A  B  A  B
0  1  6  1  6
1  2  7  2  7
2  3  8  3  8
3  4  9  4  9
4  5  0  5  0
******************************
   A  B
0  1  6
1  2  7
2  3  8
3  4  9
4  5  0
0  1  6
1  2  7
2  3  8
3  4  9
4  5  0

 

你可能感兴趣的:(Python)