Python | Numpy.dsplit() method (original) (raw)
Last Updated : 17 Sep, 2019
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 as np
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 as np
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]]])]
Similar Reads
- Python | Numpy.expand_dims() method With the help of Numpy.expand_dims() method, we can get the expanded dimensions of an array by using Numpy.expand_dims() method. Syntax : Numpy.expand_dims() Return : Return the expanded array. Example #1 : In this example we can see that using Numpy.expand_dims() method, we are able to get the expa 1 min read
- Python | numpy.fill_diagonal() method With the help of numpy.fill_diagonal() method, we can get filled the diagonals of numpy array with the value passed as the parameter in numpy.fill_diagonal() method. Syntax : numpy.fill_diagonal(array, value) Return : Return the filled value in the diagonal of an array. Example #1 : In this example 1 min read
- numpy.load() in Python numpy.load() function return the input array from a disk file with npy extension(.npy). Syntax : numpy.load(file, mmap_mode=None, allow_pickle=True, fix_imports=True, encoding='ASCII') Parameters: file : : file-like object, string, or pathlib.Path.The file to read. File-like objects must support the 2 min read
- numpy.matrix() in Python This class returns a matrix from a string of data or array-like object. Matrix obtained is a specialised 2D array. Syntax : numpy.matrix(data, dtype = None) : Parameters : data : data needs to be array-like or string dtype : Data type of returned array. Returns : data interpreted as a matrix # Pytho 1 min read
- numpy.dot() in Python numpy.dot(vector_a, vector_b, out = None) returns the dot product of vectors a and b. It can handle 2D arrays but considers them as matrix and will perform matrix multiplication. For N dimensions it is a sum-product over the last axis of a and the second-to-last of b : dot(a, b)[i,j,k,m] = sum(a[i,j 2 min read
- numpy.invert() in Python numpy.invert() function is used to Compute the bit-wise Inversion of an array element-wise. It computes the bit-wise NOT of the underlying binary representation of the integers in the input arrays. For signed integer inputs, the two’s complement is returned. In a two’s-complement system negative num 2 min read
- numpy.log() in Python The numpy.log() is a mathematical function that helps user to calculate Natural logarithm of x where x belongs to all the input array elements. Natural logarithm log is the inverse of the exp(), so that log(exp(x)) = x. The natural logarithm is log in base e. Syntax :numpy.log(x[, out] = ufunc 'log1 4 min read
- Python | Numpy MaskedArray.__div__ numpy.ma.MaskedArray class is a subclass of ndarray designed to manipulate numerical arrays with missing data. With the help of Numpy MaskedArray.__div__ we can divide a particular value that is provided as a parameter in the MaskedArray.__div__() method. Syntax: numpy.MaskedArray.__div__ Return: Di 1 min read
- numpy.diff() in Python numpy.diff(arr[, n[, axis]]) function is used when we calculate the n-th order discrete difference along the given axis. The first order difference is given by out[i] = arr[i+1] - arr[i] along the given axis. If we have to calculate higher differences, we are using diff recursively. Syntax: numpy.di 2 min read
- numpy.diag() in Python numpy.diag(a, k=0) : Extracts and construct a diagonal array Parameters : a : array_like k : [int, optional, 0 by default] Diagonal we require; k>0 means diagonal above main diagonal or vice versa. Returns : ndarray Python Code # Python Programming illustrating # numpy.diag method import numpy as 1 min read