# xarray.DataArray.dropna

#### DataArray.dropna(dim, , how='any', thresh=None)[[source]](https://github.com/pydata/xarray/blob/v2026.09.0/xarray/core/dataarray.py#L3550-L3625)

Returns a new array with dropped labels for missing values along
the provided dimension.

* **Parameters:**
  * **dim** (`Hashable`) – Dimension along which to drop missing values. Dropping along
    multiple dimensions simultaneously is not yet supported.
  * **how** (`{"any", "all"}`, *default*: `"any"`) –
    - any : if any NA values are present, drop that label
    - all : if all values are NA, drop that label
  * **thresh** ([`int`](https://docs.python.org/3/builtins/functions.html#int) or [`None`](https://docs.python.org/3/builtins/constants.html#None), *default*: [`None`](https://docs.python.org/3/builtins/constants.html#None)) – If supplied, require this many non-NA values.
* **Returns:**
  **dropped** ([`DataArray`](xarray.DataArray.html.md#xarray.DataArray))

### Examples

<div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesShowIframe('3f27d87c-19a4-4ce8-aee7-58eb797b0f6c','efb8af03-7364-402f-94d6-5cea19101d2f','9a462789-6977-4919-87e4-299f28089a71','../lite/tree/../notebooks/index.html?path=538c175a_8631_4294_a9d0_bda6865f5eb2.ipynb','None')">Try it in your browser!</button></div>
```pycon
>>> temperature = [
...     [0, 4, 2, 9],
...     [np.nan, np.nan, np.nan, np.nan],
...     [np.nan, 4, 2, 0],
...     [3, 1, 0, 0],
... ]
>>> da = xr.DataArray(
...     data=temperature,
...     dims=["Y", "X"],
...     coords=dict(
...         lat=("Y", np.array([-20.0, -20.25, -20.50, -20.75])),
...         lon=("X", np.array([10.0, 10.25, 10.5, 10.75])),
...     ),
... )
>>> da
<xarray.DataArray (Y: 4, X: 4)> Size: 128B
array([[ 0.,  4.,  2.,  9.],
       [nan, nan, nan, nan],
       [nan,  4.,  2.,  0.],
       [ 3.,  1.,  0.,  0.]])
Coordinates:
    lat      (Y) float64 32B -20.0 -20.25 -20.5 -20.75
    lon      (X) float64 32B 10.0 10.25 10.5 10.75
Dimensions without coordinates: Y, X
```

```pycon
>>> da.dropna(dim="Y", how="any")
<xarray.DataArray (Y: 2, X: 4)> Size: 64B
array([[0., 4., 2., 9.],
       [3., 1., 0., 0.]])
Coordinates:
    lat      (Y) float64 16B -20.0 -20.75
    lon      (X) float64 32B 10.0 10.25 10.5 10.75
Dimensions without coordinates: Y, X
```

Drop values only if all values along the dimension are NaN:

```pycon
>>> da.dropna(dim="Y", how="all")
<xarray.DataArray (Y: 3, X: 4)> Size: 96B
array([[ 0.,  4.,  2.,  9.],
       [nan,  4.,  2.,  0.],
       [ 3.,  1.,  0.,  0.]])
Coordinates:
    lat      (Y) float64 24B -20.0 -20.5 -20.75
    lon      (X) float64 32B 10.0 10.25 10.5 10.75
Dimensions without coordinates: Y, X
```

<div id="9a462789-6977-4919-87e4-299f28089a71" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('3f27d87c-19a4-4ce8-aee7-58eb797b0f6c','9a462789-6977-4919-87e4-299f28089a71')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('3f27d87c-19a4-4ce8-aee7-58eb797b0f6c','9a462789-6977-4919-87e4-299f28089a71')">Open In Tab</button></div><div id="efb8af03-7364-402f-94d6-5cea19101d2f" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>
