# xarray.DataArray.drop_vars

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

Return 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('66f3e44d-27e1-4299-bf1d-2a18f933e7a4','f5dce173-3cb7-4b9f-9dad-da7b07bca8e0','b9c73445-d9b6-43ec-a3ea-aa250621f276','../lite/tree/../notebooks/index.html?path=156dd7ad_cb8e_4287_b8af_25b739bc3ebf.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="b9c73445-d9b6-43ec-a3ea-aa250621f276" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('66f3e44d-27e1-4299-bf1d-2a18f933e7a4','b9c73445-d9b6-43ec-a3ea-aa250621f276')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('66f3e44d-27e1-4299-bf1d-2a18f933e7a4','b9c73445-d9b6-43ec-a3ea-aa250621f276')">Open In Tab</button></div><div id="f5dce173-3cb7-4b9f-9dad-da7b07bca8e0" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>
