numpy.extract() in Python Last Updated : 08 Mar, 2024 Summarize Comments Improve Suggest changes Share Like Article Like Report The numpy.extract() function returns elements of input_array if they satisfy some specified condition. Syntax: numpy.extract(condition, array) Parameters : array : Input array. User apply conditions on input_array elements condition : [array_like]Condition on the basis of which user extract elements. Applying condition on input_array, if we print condition, it will return an array filled with either True or False. Array elements are extracted from the Indices having True value. Returns : Array elements that satisfy the condition. Python # Python Program illustrating # numpy.compress method import numpy as geek array = geek.arange(10).reshape(5, 2) print("Original array : \n", array) a = geek.mod(array, 4) !=0 # This will show element status of satisfying condition print("\nArray Condition a : \n", a) # This will return elements that satisfy condition "a" condition print("\nElements that satisfy condition a : \n", geek.extract(a, array)) b = array - 4 == 1 # This will show element status of satisfying condition print("\nArray Condition b : \n", b) # This will return elements that satisfy condition "b" condition print("\nElements that satisfy condition b : \n", geek.extract(b, array)) Output : Original array : [[0 1] [2 3] [4 5] [6 7] [8 9]] Array Condition a : [[False True] [ True True] [False True] [ True True] [False True]] Elements that satisfy condition a : [1 2 3 5 6 7 9] Array Condition b : [[False False] [False False] [False True] [False False] [False False]] Elements that satisfy condition b : [5] Note : Also, these codes won't run on online IDE's. So please, run them on your systems to explore the working. Comment More infoAdvertise with us Next Article numpy.extract() in Python M Mohit Gupta Improve Article Tags : Python Python-numpy Python numpy-Sorting Searching Practice Tags : python Similar Reads numpy.take() in Python The numpy.take() function returns elements from array along the mentioned axis and indices. Syntax: numpy.take(array, indices, axis = None, out = None, mode ='raise') Parameters : array : array_like, input array indices : index of the values to be fetched axis : [int, optional] axis over which we ne 2 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.fromstring() function â Python numpy.fromstring() function create a new one-dimensional array initialized from text data in a string. Syntax : numpy.fromstring(string, dtype = float, count = -1, sep = ' ') Parameters : string : [str] A string that contained the data. dtype : [data-type, optional] Data-type of the array. Default d 1 min read Python NumPy Numpy is a general-purpose array-processing package. It provides a high-performance multidimensional array object, and tools for working with these arrays. It is the fundamental package for scientific computing with Python.Besides its obvious scientific uses, Numpy can also be used as an efficient m 6 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 Like