# xarray.DataArray.dropna

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

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('44f1a37f-a338-4073-a92d-ec29c37f629e','082d4114-fbce-4bb9-abe7-5ca2a79a58ff','53f99c45-d425-4243-8aaa-6238dd092da3','../lite/tree/../notebooks/index.html?path=8b57e6f3_0644_4ff0_b80f_ba8d1b74117b.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="53f99c45-d425-4243-8aaa-6238dd092da3" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('44f1a37f-a338-4073-a92d-ec29c37f629e','53f99c45-d425-4243-8aaa-6238dd092da3')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('44f1a37f-a338-4073-a92d-ec29c37f629e','53f99c45-d425-4243-8aaa-6238dd092da3')">Open In Tab</button></div><div id="082d4114-fbce-4bb9-abe7-5ca2a79a58ff" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>
