numpy.argwhere() in Python Last Updated : 24 Dec, 2018 Comments Improve Suggest changes Like Article Like Report numpy.argwhere() function is used to find the indices of array elements that are non-zero, grouped by element. Syntax : numpy.argwhere(arr) Parameters : arr : [array_like] Input array. Return : [ndarray] Indices of elements that are non-zero. Indices are grouped by element. Code #1 : Python3 # Python program explaining # argwhere() function import numpy as geek # input array in_arr = [[ 2, 0, 7], [ 0, 5, 9]] print ("Input array : ", in_arr) out_arr = geek.argwhere(in_arr) print ("Output indices of non zero array element: \n", out_arr) Output: Input array : [[2, 0, 7], [0, 5, 9]] Output indices of non zero array element: [[0 0] [0 2] [1 1] [1 2]] Code #2 : Python3 # Python program explaining # argwhere() function import numpy as geek # input array in_arr = geek.arange(8).reshape(4, 2) print ("Input array : ", in_arr) out_arr = geek.argwhere(in_arr>4) print ("Output indices greater than 4: \n", out_arr) Output: Input array : [[0 1] [2 3] [4 5] [6 7]] Output indices greater than 4: [[2 1] [3 0] [3 1]] Comment More infoAdvertise with us Next Article numpy.argwhere() in Python jana_sayantan Follow Improve Article Tags : Python Python-numpy Python numpy-Sorting Searching Practice Tags : python Similar Reads numpy.argsort() in Python numpy.argsort() is a function in NumPy that returns the indices that would sort an array. In other words, it gives you the indices that you would use to reorder the elements in an array to be in sorted order. Example: Pythonimport numpy as np a = np.array([2, 0, 1, 5, 4, 1, 9]) idx = np.argsort(a) p 3 min read numpy.where() in Python We will explore the basics of numpy.where(), how it works, and practical use cases to illustrate its importance in data manipulation and analysis.Syntax of numpy.where()Syntax :numpy.where(condition[, x, y]) Parameters condition: A condition that tests elements of the array.x (optional): Values from 3 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 numpy.apply_along_axis() in Python The numpy.apply_along_axis() function helps us to apply a required function to 1D slices of the given array. 1d_func(ar, *args) : works on 1-D arrays, where ar is 1D slice of arr along axis. Syntax : numpy.apply_along_axis(1d_func, axis, array, *args, **kwargs) Parameters : 1d_func : the required fu 3 min read numpy.who function - Python numpy.who() function print the NumPy arrays in the given dictionary. Syntax : numpy.who(vardict = None) Parameters : vardict : [dict, optional] A dictionary possibly containing ndarrays. Return : Returns âNoneâ. If there is no dictionary passed in or vardict is None then returns NumPy arrays in the 1 min read Cmdparse module in Python The Class which provides a simple framework for writing line-oriented command interpreters is called cmd class. These are often useful for administrative tools, prototypes and test harnesses that will later be wrapped in a more sophisticated interface. The command-line interface can be easily made u 6 min read Getopt module in Python The getopt module is a parser for command-line options based on the convention established by the Unix getopt() function. It is in general used for parsing an argument sequence such as sys.argv. In other words, this module helps scripts to parse command-line arguments in sys.argv. It works similar t 2 min read numpy.info() function in Python In Numpy we can get all the information about the function, class, or module like what will the parameter and what will be the type of the return value with the help of numpy.info() function. This function returns the help information for a function, class, or module. Syntax: numpy.info(numpy.info(o 1 min read numpy.imag() function - Python numpy.imag() function return the imaginary part of the complex argument. Syntax : numpy.imag(arr) Parameters : arr : [array_like] Input array. Return : [ndarray or scalar] The imaginary component of the complex argument. If val is real, the type of val is used for the output. If val has complex elem 1 min read Python | numpy.lookfor() method With the help of numpy.lookfor() method, we can get the information about the module in the numpy by using numpy.lookfor() method. Syntax : numpy.lookfor(module_name) Return : Return the information about the module. Example #1 : In this example we can see that by using numpy.lookfor() method, we ar 1 min read Like