# xarray.Variable.item

#### Variable.item(\*args)[[source]](https://github.com/pydata/xarray/blob/main/xarray/computation/ops.py#L129-L130)

Copy an element of an array to a standard Python scalar and return it.

* **Parameters:**
  **\*args** (`Arguments (variable number` and `type)`) –
  * none: in this case, the method only works for arrays
    with one element (a.size == 1), which element is
    copied into a standard Python scalar object and returned.
  * int_type: this argument is interpreted as a flat index into
    the array, specifying which element to copy and return.
  * tuple of int_types: functions as does a single int_type argument,
    except that the argument is interpreted as an nd-index into the
    array.
* **Returns:**
  **z** (`Standard Python scalar object`) – A copy of the specified element of the array as a suitable
  Python scalar

### Notes

When the data type of a is longdouble or clongdouble, item() returns
a scalar array object because there is no available Python scalar that
would 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 up
access to elements of the array and doing arithmetic on elements of the
array using Python’s optimized math.

### Examples

<div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesShowIframe('fe206f08-6700-4934-ac7f-8dc3ff192b01','d5fe6638-c021-4d84-b37b-e145395691c2','66e2ba03-3ce4-4298-a965-28e1045e14aa','../lite/tree/../notebooks/index.html?path=612c9a88_7daf_43e6_9c9e_c698ea0e4ab5.ipynb','None')">Try it in your browser!</button></div>
```pycon
>>> import numpy as np
>>> np.random.seed(123)
>>> x = np.random.randint(9, size=(3, 3))
>>> x
array([[2, 2, 6],
       [1, 3, 6],
       [1, 0, 1]])
>>> x.item(3)
1
>>> x.item(7)
0
>>> x.item((0, 1))
2
>>> x.item((2, 2))
1
```

For an array with object dtype, elements are returned as-is.

```pycon
>>> a = np.array([np.int64(1)], dtype=np.object_)
>>> a.item() #return np.int64
np.int64(1)
```

<div id="66e2ba03-3ce4-4298-a965-28e1045e14aa" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('fe206f08-6700-4934-ac7f-8dc3ff192b01','66e2ba03-3ce4-4298-a965-28e1045e14aa')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('fe206f08-6700-4934-ac7f-8dc3ff192b01','66e2ba03-3ce4-4298-a965-28e1045e14aa')">Open In Tab</button></div><div id="d5fe6638-c021-4d84-b37b-e145395691c2" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>
