Sunday, July 26, 2026
HomeLanguagesPython | Numpy.dsplit() method

Python | Numpy.dsplit() method

With the help of Numpy.dsplit()() method, we can get the splitted dimensions of an array by using Numpy.dsplit()() method.

Syntax : Numpy.dsplit(numpy.array(), split_size)

Return : Return the array having splitted dimensions.

Example #1 :

In this example we can see that using Numpy.expand_dims() method, we are able to get the splitted dimensions using this method.




# import numpy
import numpy as np
  
# using Numpy.dsplit() method
gfg = np.array([[1, 2, 5],
                [3, 4, 10],
                [5, 6, 15],
                [7, 8, 20]])
  
gfg = gfg.reshape(1, 2, 6)
print(gfg)
  
gfg = np.dsplit(gfg, 2)
print(gfg)


Output :

[[[ 1 2 5 3 4 10]
[ 5 6 15 7 8 20]]]

[array([[[ 1, 2, 5],
[ 5, 6, 15]]]),
array([[[ 3, 4, 10],
[ 7, 8, 20]]])]

Example #2 :




# import numpy
import numpy as np
  
# using Numpy.expand_dims() method
gfg = np.array([[1, 2], [7, 8], [5, 10]])
gfg = gfg.reshape(1, 2, 3)
print(gfg)
  
gfg = np.dsplit(gfg, 3)
print(gfg)


Output :

[[[ 1 2 7]
[ 8 5 10]]]

[array([[[1],
[8]]]), array([[[2],
[5]]]), array([[[ 7],
[10]]])]

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32520 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6903 POSTS0 COMMENTS
Nicole Veronica
12017 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12115 POSTS0 COMMENTS
Shaida Kate Naidoo
7023 POSTS0 COMMENTS
Ted Musemwa
7265 POSTS0 COMMENTS
Thapelo Manthata
6980 POSTS0 COMMENTS
Umr Jansen
6972 POSTS0 COMMENTS