np.r_:连接两个矩阵,就是把两矩阵上下相加,要求列数相等,类似于pandas中的concat()

np.c_:连接两个矩阵,就是把两矩阵左右相加,要求行数相等,类似于pandas中的merge()

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])

结果如下:

[1 2 3 4 5 6]
[[1 4] [2 5] [3 6]]
[[1 4 1] [2 5 2] [3 6 3]]

 

 

参考文献:

【1】numpy中np.c_和np.r_











 

相关文章:

  • 2022-01-19
  • 2021-06-17
  • 2022-01-01
  • 2021-11-21
  • 2022-12-23
  • 2022-12-23
  • 2021-11-18
  • 2022-12-23
猜你喜欢
  • 2021-12-06
  • 2023-03-20
  • 2021-09-24
  • 2022-12-23
  • 2021-12-10
  • 2021-07-23
相关资源
相似解决方案