You can get the same with:

import numpy as np
a = np.arange(7, 13).reshape(2, 3)
b = np.arange(1, 7).reshape(2, 3)
z = np.stack((a, b), axis=1)
print(z)
# [[[ 7  8  9]
#   [ 1  2  3]]
# 
#  [[10 11 12]
#   [ 4  5  6]]]
Answer from javidcf on Stack Overflow
🌐
NumPy
numpy.org › doc › 1.25 › reference › generated › numpy.row_stack.html
numpy.row_stack — NumPy v1.25 Manual
This function makes most sense ... concatenate, stack and block provide more general stacking and concatenation operations. np.row_stack is an alias for vstack....
🌐
Educative
educative.io › answers › what-is-the-numpyrowstack-function-in-numpy
What is the numpy.row_stack() function in NumPy?
The row_stack() function in NumPy is used to stack or arrange arrays in sequence vertically (row-wise).
🌐
NumPy
numpy.org › doc › 1.21 › reference › generated › numpy.row_stack.html
numpy.row_stack — NumPy v1.21 Manual
June 22, 2021 - Stack 1-D arrays as columns into a 2-D array. ... Split an array into multiple sub-arrays vertically (row-wise).
🌐
TutorialsPoint
tutorialspoint.com › numpy › numpy_row_stack_function.htm
Numpy row_stack() Function
The numpy.row_stack() function stacks 1D arrays into rows of a 2D array, resulting in an array with shape (m, n), where m is the number of arrays and n is the length of the arrays.
🌐
SciPy
docs.scipy.org › doc › numpy-1.13.0 › reference › generated › numpy.ma.row_stack.html
numpy.ma.row_stack — NumPy v1.13 Manual
Stack arrays in sequence vertically (row wise). Take a sequence of arrays and stack them vertically to make a single array. Rebuild arrays divided by vsplit. This function continues to be supported for backward compatibility, but you should prefer np.concatenate or np.stack.
🌐
NumPy
numpy.org › doc › 1.23 › reference › generated › numpy.row_stack.html
numpy.row_stack — NumPy v1.23 Manual
Stack 1-D arrays as columns into a 2-D array. ... Split an array into multiple sub-arrays vertically (row-wise).
🌐
NumPy
numpy.org › doc › 1.20 › › reference › generated › numpy.row_stack.html
numpy.row_stack — NumPy v1.20 Manual
January 31, 2021 - Stack 1-D arrays as columns into a 2-D array. ... Split an array into multiple sub-arrays vertically (row-wise).
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › python › numpy-ma-row_stack-in-python
numpy.ma.row_stack() in Python - GeeksforGeeks
July 16, 2018 - Row-wise stacked arrays Code #1: Explaining row_stack() Python3 1== # 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) Output : arr : [[1] [2] [3]] arr1 : [[1] [2] [3]] Code #2: Error generated with row_stack() Python3 1== # 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) Output : ValueError: all the input array dimensions except for the concatenation axis must match exactly.
🌐
GeeksforGeeks
geeksforgeeks.org › python › numpy-stack-in-python
numpy.stack() in Python - GeeksforGeeks
December 13, 2025 - Python · import numpy as np x ... [ 6 12]]] Explanation: axis=0: stacks arrays as two “layers” of a 3D array. axis=1: stacks row-wise....
🌐
w3resource
w3resource.com › python-exercises › numpy › python-numpy-exercise-130.php
Python NumPy: Stack 1-D arrays as row wise - w3resource
August 29, 2025 - # Importing the NumPy library and aliasing it as 'np' import numpy as np # Printing a message indicating the original arrays will be displayed print("\nOriginal arrays:") # Creating a NumPy array 'x' with elements 1, 2, and 3 x = np.array((1, 2, 3)) # Creating another NumPy array 'y' with elements 2, 3, and 4 y = np.array((2, 3, 4)) # Printing a message for Array-1 and displaying the contents of array 'x' print("Array-1") print(x) # Printing a message for Array-2 and displaying the contents of array 'y' print("Array-2") print(y) # Stacking Array-1 'x' and Array-2 'y' as rows using np.row_stack() new_array = np.row_stack((x, y)) # Printing a message indicating the stacking of 1-D arrays as rows and displaying the resulting new array print("\nStack 1-D arrays as rows wise:") print(new_array)
🌐
Sling Academy
slingacademy.com › article › using-numpy-row_stack-function-4-examples
Using numpy.row_stack() function (4 examples) - Sling Academy
February 29, 2024 - It is equivalent to numpy.vstack() but specifically designed for row-wise stacking, thus making array concatenation intuitive.
🌐
Towards Data Science
towardsdatascience.com › home › data science › np.stack() - how to stack two arrays in numpy and python
np.stack() - How To Stack two Arrays in Numpy And Python | Towards Data Science
January 10, 2023 - Put simply, it allows you to join arrays row-wise (default) or column-wise, depending on the parameter values you specify. We'll go over the fundamentals and the function signature, and then jump into examples in Python.
🌐
Medium
medium.com › nerd-for-tech › stacking-and-splitting-numpy-arrays-like-a-pro-part-1-b04ed83c8442
Stacking and Splitting NumPy arrays like a Pro: Part 1 | by Devansh Sheth | Medium
April 4, 2023 - Numpy’s stack function is used to join multiple numpy arrays along a new axis and return a numpy array. One of the main requirement to keep in mind is that arrays should have same shape and dimension.