# xarray.DataArray.dropna

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

Return a new array with dropped labels for missing values along a 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('2940dba9-159d-4dca-b2f0-e6403cd1c8a0','bed221ab-4016-4ba2-86d3-2d2bb23ab0e0','2c9f8048-2c30-4d6e-bcd3-c1883d1e0595','../lite/tree/../notebooks/index.html?path=f1c28829_dc9a_440f_9d05_378fa8fad590.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="2c9f8048-2c30-4d6e-bcd3-c1883d1e0595" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('2940dba9-159d-4dca-b2f0-e6403cd1c8a0','2c9f8048-2c30-4d6e-bcd3-c1883d1e0595')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('2940dba9-159d-4dca-b2f0-e6403cd1c8a0','2c9f8048-2c30-4d6e-bcd3-c1883d1e0595')">Open In Tab</button></div><div id="bed221ab-4016-4ba2-86d3-2d2bb23ab0e0" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>
