numpy.ndarray.ndim() method | Python (original) (raw)
Last Updated : 26 Mar, 2020
numpy.ndarray.ndim()
function return the number of dimensions of an array.
Syntax : numpy.ndarray.ndim(arr)
Parameters :
arr : [array_like] Input array. If it is not already an ndarray, a conversion is attempted.Return : [int] Return the number of dimensions in arr.
Code #1 :
import
numpy as geek
arr
=
geek.array([
1
,
2
,
3
,
4
])
gfg
=
arr.ndim
print
(gfg)
Output :
1
Code #2 :
import
numpy as geek
arr
=
[[
1
,
2
,
3
], [
4
,
5
,
6
]]
gfg
=
geek.ndim(arr)
print
(gfg)
Output :
2
Similar Reads
- Python | Numpy ndarray.__imod__() With the help of Numpy ndarray.__imod__(), every element in an array is operated on binary operator i.e mod(%). Remember we can use any type of values in an array and value for mod is applied as the parameter in ndarray.__imod__(). Syntax: ndarray.__imod__($self, value, /) Return: self%=value Exampl 1 min read
- Python | Numpy numpy.ndarray.__divmod__() With the help of Numpy numpy.ndarray.__divmod__() method, we will get two arrays one is having elements that is divided by value that is provided in numpy.ndarray.__divmod__() method and second is having elements that perform mod operation with same value as provided in numpy.ndarray.__divmod__() me 1 min read
- Python | Numpy numpy.ndarray.__add__() With the help of Numpy numpy.ndarray.__add__(), we can add a particular value that is provided as a parameter in the ndarray.__add__() method. Value will be added to each and every element in a numpy array. Syntax: ndarray.__add__($self, value, /) Return: self+value Example #1 : In this example we c 1 min read
- numpy.ndarray.itemsize() method | Python numpy.ndarray.itemsize() function return the length of one array element in bytes. Syntax : numpy.ndarray.itemsize(arr) Parameters : arr : [array_like] Input array. Return : [int] The length of one array element in bytes Code #1 : # Python program explaining # numpy.ndarray.itemsize() function # imp 1 min read
- Python | Numpy numpy.ndarray.__iadd__() With the help of numpy.ndarray.__iadd__() method, we can add a particular value that is provided as a parameter in the ndarray.__iadd__() method. Value will be added to every element in a numpy array. Syntax: ndarray.__iadd__($self, value, /) Return: self+=value Example #1 : In this example we can s 1 min read
- Python | Numpy numpy.ndarray.__imul__() With the help of numpy.ndarray.__imul__() method, we can multiply a particular value that is provided as a parameter in the ndarray.__imul__() method. Value will be multiplied to every element in a numpy array. Syntax: ndarray.__imul__($self, value, /)Return: self*=value Example #1 : In this example 1 min read
- Python | Numpy ndarray.__ior__() With the help of Numpy ndarray.__ior__() method, we can get the elements that is OR by the value that is provided as a parameter in numpy.ndarray.__ior__() method. Syntax: ndarray.__ior__($self, value, /) Return: self|=value Example #1 : In this example we can see that every element is or by the val 1 min read
- Python | Numpy ndarray.item() With the help of numpy.ndarray.item() method, we can fetch the data elements that is found at the given index on numpy array. Remember we can give index as one dimensional parameter or can be two dimensional. Parameters: *args : Arguments (variable number and type) -> none: This argument only works 1 min read
- Python | Numpy ndarray.__iand__() With the help of Numpy ndarray.__iand__() method, we can get the elements that is anded by the value that is provided as a parameter in numpy.ndarray.__iand__() method. Syntax: ndarray.__iand__($self, value, /) Return: self&=value Example #1 : In this example we can see that every element is and 1 min read
- Python | Numpy ndarray.__copy__() With the help of Numpy ndarray.__copy__() method, we can make a copy of all the data elements that is present in numpy array. If you change any data element in the copy, it will not affect the original numpy array. Syntax : numpy.__copy__() Return : Copy of all the data elements Example #1 : In this 1 min read