Python | Numpy dstack() method
With the help of numpy.dstack() method, we can get the combined array index by index and store like a stack by using numpy.dstack() method.
Syntax :
numpy.dstack((array1, array2))Return : Return combined array index by index.
Example #1 :
In this example we can see that by using numpy.dstack() method, we are able to get the combined array in a stack index by index.
# import numpy import numpy as np gfg1 = np.array([1, 2, 3]) gfg2 = np.array([4, 5, 6]) # using numpy.dstack() method print(np.dstack((gfg1, gfg2))) |
Output :
[[[1 4]
[2 5]
[3 6]]]
Example #2 :
# import numpy import numpy as np gfg1 = np.array([[10], [2], [13]]) gfg2 = np.array([[41], [55], [6]]) # using numpy.dstack() method print(np.dstack((gfg1, gfg2))) |
Output :
[[[10 41]]
[[ 2 55]]
[[13 6]]]
Recommended Posts:
- Python | numpy.ma.ids() method
- Python | Numpy np.ma.innerproduct() method
- Python | Numpy getmask() method
- Python | Numpy np.multinomial() method
- Python | Numpy np.multivariate_normal() method
- Python | Numpy np.negative_binomial() method
- Python | Numpy np.lognormal() method
- Python | numpy.datetime64() method
- Python | numpy.isin() method
- Python | numpy.lookfor() method
- Python | numpy.busday_count() method
- Python | numpy.printoptions() method
- python | Numpy masked_equal() method
- Python | Numpy expandtabs() method
- Python | Numpy fromrecords() method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



