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.
*args : Arguments (variable number and type)
-> none: This argument only works when size of an array is 1.
-> int_type: This argument is interpreted as a flat index into the array, specifying which element to return.
-> tuple of int_types: This argument is interpreted as a two dimensional array, by specifying which element to return.
Returns: Copy of an Item
Example #1 :
In this example we can see that by specifying the argument in
ndarray.item() method, we can have the element if it existed on this index.
Example #2 :