📜  Python中的 numpy.ma.row_stack()

📅  最后修改于: 2022-05-13 01:54:50.550000             🧑  作者: Mango

Python中的 numpy.ma.row_stack()

numpy.ma.row_stack() :此函数有助于以垂直方式逐行堆叠数组。

参数 :

结果 :

Row-wise stacked arrays

代码 #1:解释 row_stack()

# importing libraries
import numpy as np
  
# row_stacking array
a = np.array([1, 2, 3])
arr = np.ma.row_stack (a)
  
print ("arr : \n", arr)
  
# row_stacking array
b = np.array([[1], [2], [3]])
arr1 = np.ma.row_stack (b)
  
print ("\narr1 : \n", arr1)

输出 :

arr : 
 [[1]
 [2]
 [3]]

arr1 : 
 [[1]
 [2]
 [3]]


代码 #2:使用 row_stack() 生成的错误

# importing libraries
import numpy as np
  
# row_stacking array
  
b = np.array([[1, 1], [2], [3]])
arr1 = np.ma.row_stack (b)
  
print ("\narr1 : \n", arr1)

输出 :