# xarray.DataArray.drop_vars

#### DataArray.drop_vars(names, , errors='raise')[[source]](https://github.com/pydata/xarray/blob/main/xarray/core/dataarray.py#L3307-L3381)

Returns an array with dropped variables.

* **Parameters:**
  * **names** (`Hashable` or [iterable](https://docs.python.org/3/glossary.html#term-iterable) of `Hashable` or `Callable`) – Name(s) of variables to drop. If a Callable, this object is passed as its
    only argument and its result is used.
  * **errors** (`{"raise", "ignore"}`, *default*: `"raise"`) – If ‘raise’, raises a ValueError error if any of the variable
    passed are not in the dataset. If ‘ignore’, any given names that are in the
    DataArray are dropped and no error is raised.
* **Returns:**
  **dropped** ([`Dataset`](xarray.Dataset.html.md#xarray.Dataset)) – New Dataset copied from self with variables removed.

### Examples

<div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesShowIframe('96c48893-6ce2-46b8-aa09-ed941ddd1f6c','421f1169-a28c-4d36-9e67-6c864f583f0a','c89c518e-f333-4759-8c8c-1c569be80cea','../lite/tree/../notebooks/index.html?path=12a84027_0242_4bb2_85b1_1c6007902ba0.ipynb','None')">Try it in your browser!</button></div>
```pycon
>>> data = np.arange(12).reshape(4, 3)
>>> da = xr.DataArray(
...     data=data,
...     dims=["x", "y"],
...     coords={"x": [10, 20, 30, 40], "y": [70, 80, 90]},
... )
>>> da
<xarray.DataArray (x: 4, y: 3)> Size: 96B
array([[ 0,  1,  2],
       [ 3,  4,  5],
       [ 6,  7,  8],
       [ 9, 10, 11]])
Coordinates:
  * x        (x) int64 32B 10 20 30 40
  * y        (y) int64 24B 70 80 90
```

Removing a single variable:

```pycon
>>> da.drop_vars("x")
<xarray.DataArray (x: 4, y: 3)> Size: 96B
array([[ 0,  1,  2],
       [ 3,  4,  5],
       [ 6,  7,  8],
       [ 9, 10, 11]])
Coordinates:
  * y        (y) int64 24B 70 80 90
Dimensions without coordinates: x
```

Removing a list of variables:

```pycon
>>> da.drop_vars(["x", "y"])
<xarray.DataArray (x: 4, y: 3)> Size: 96B
array([[ 0,  1,  2],
       [ 3,  4,  5],
       [ 6,  7,  8],
       [ 9, 10, 11]])
Dimensions without coordinates: x, y
```

```pycon
>>> da.drop_vars(lambda x: x.coords)
<xarray.DataArray (x: 4, y: 3)> Size: 96B
array([[ 0,  1,  2],
       [ 3,  4,  5],
       [ 6,  7,  8],
       [ 9, 10, 11]])
Dimensions without coordinates: x, y
```

<div id="c89c518e-f333-4759-8c8c-1c569be80cea" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('96c48893-6ce2-46b8-aa09-ed941ddd1f6c','c89c518e-f333-4759-8c8c-1c569be80cea')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('96c48893-6ce2-46b8-aa09-ed941ddd1f6c','c89c518e-f333-4759-8c8c-1c569be80cea')">Open In Tab</button></div><div id="421f1169-a28c-4d36-9e67-6c864f583f0a" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>
