原文地址:https://blog.csdn.net/yj1556492839/article/details/79031693
例子
import numpy as np
a = np.array([1, 2, 3])
b = np.array([4, 5, 6])
c = np.c_[a,b]
print(np.r_[a,b])
print(c)
print(np.c_[c,a])
np.r_ 是按行连接两个矩阵,就是把两矩阵上下相连,要求列数相等,类似于pandas中的 concat()。
np.c_ 是按列连接两个矩阵,就是把两矩阵左右相连,要求行数相等,类似于pandas中的 merge()。
结果:
[1 2 3 4 5 6]
[[1 4]
[2 5]
[3 6]]
[[1 4 1]
[2 5 2]
[3 6 3]]
在 numpy 中,一个列表虽然是横着表示的,但它其实是列向量。