numpy.ndarray.ndim() method | Python Last Updated : 26 Mar, 2020 Comments Improve Suggest changes Like Article Like Report 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 : Python3 # Python program explaining # numpy.ndarray.ndim() function # importing numpy as geek import numpy as geek arr = geek.array([1, 2, 3, 4]) gfg = arr.ndim print (gfg) Output : 1 Code #2 : Python3 # Python program explaining # numpy.ndarray.ndim() function # importing numpy as geek import numpy as geek arr = [[1, 2, 3], [4, 5, 6]] gfg = geek.ndim(arr) print (gfg) Output : 2 Comment More infoAdvertise with us Next Article numpy.ndarray.ndim() method | Python sanjoy_62 Follow Improve Article Tags : Machine Learning Python-numpy Python numpy-ndarray python Practice Tags : Machine Learningpython Similar Reads 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 : Python3 # Python program explaining # numpy.ndarray.itemsize() functi 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 2 min read NumPy Array in Python NumPy (Numerical Python) is a powerful library for numerical computations in Python. It is commonly referred to multidimensional container that holds the same data type. It is the core data structure of the NumPy library and is optimized for numerical and scientific computation in Python. Table of C 2 min read numpy.ndarray.flat() in Python The numpy.ndarray.flat() function is used as a 1_D iterator over N-dimensional arrays. It is not a subclass of, Pythonâs built-in iterator object, otherwise it a numpy.flatiter instance. Syntax : numpy.ndarray.flat() Parameters : index : [tuple(int)] index of the values to iterate Return :  1-D i 3 min read numpy.asarray() in Python numpy.asarray()function is used when we want to convert input to an array. Input can be lists, lists of tuples, tuples, tuples of tuples, tuples of lists and arrays. Syntax : numpy.asarray(arr, dtype=None, order=None) Parameters : arr : [array_like] Input data, in any form that can be converted to a 2 min read numpy.asanyarray() in Python numpy.asanyarray()function is used when we want to convert input to an array but it pass ndarray subclasses through. Input can be scalars, lists, lists of tuples, tuples, tuples of tuples, tuples of lists and ndarrays. Syntax : numpy.asanyarray(arr, dtype=None, order=None) Parameters : arr : [array_ 2 min read numpy.ndarray.view() in Python numpy.ndarray.view() helps to get a new view of array with the same data. Syntax: ndarray.view(dtype=None, type=None)Parameters: dtype : Data-type descriptor of the returned view, e.g., float32 or int16. The default, None, results in the view having the same data-type as a. type : Python type, opti 3 min read numpy.ndarray.fill() in Python numpy.ndarray.fill() method is used to fill the numpy array with a scalar value. If we have to initialize a numpy array with an identical value then we use numpy.ndarray.fill(). Suppose we have to create a NumPy array a of length n, each element of which is v. Then we use this function as a.fill(v). 2 min read numpy.array_str() in Python numpy.array_str()function is used to represent the data of an array as a string. The data in the array is returned as a single string. This function is similar to array_repr, the difference being that array_repr also returns information on the kind of array and its data type. Syntax : numpy.array_st 2 min read Like