MaskedArray.item(*args)¶Copy an element of an array to a standard Python scalar and return it.
| Parameters: | *args : Arguments (variable number and type)
|
|---|---|
| Returns: | z : Standard Python scalar object
|
Notes
When the data type ofa is longdouble or clongdouble, item() returnsa scalar array object because there is no available Python scalar thatwould not lose information. Void arrays return a buffer object for item(),unless fields are defined, in which case a tuple is returned.
item is very similar to a[args], except, instead of an array scalar,a standard Python scalar is returned. This can be useful for speeding upaccess to elements of the array and doing arithmetic on elements of thearray using Python’s optimized math.
Examples
>>>x=np.random.randint(9,size=(3,3))>>>xarray([[3, 1, 7], [2, 8, 3], [8, 5, 3]])>>>x.item(3)2>>>x.item(7)5>>>x.item((0,1))1>>>x.item((2,2))3