# xarray.full_like

### xarray.full_like(other, fill_value, dtype=None, , chunks=None, chunked_array_type=None, from_array_kwargs=None)[[source]](https://github.com/pydata/xarray/blob/main/xarray/core/common.py#L1567-L1751)

Return a new object with the same shape and type as a given object.

Returned object will be chunked if if the given object is chunked, or if chunks or chunked_array_type are specified.

* **Parameters:**
  * **other** ([`DataArray`](xarray.DataArray.html.md#xarray.DataArray), [`Dataset`](xarray.Dataset.html.md#xarray.Dataset) or [`Variable`](xarray.Variable.html.md#xarray.Variable)) – The reference object in input
  * **fill_value** ([scalar](../user-guide/terminology.html.md#term-scalar) or [dict-like](https://docs.python.org/3/glossary.html#term-mapping)) – Value to fill the new object with before returning it. If
    other is a Dataset, may also be a dict-like mapping data
    variables to fill values.
  * **dtype** ([`dtype`](https://numpy.org/doc/stable/reference/generated/numpy.dtype.html#numpy.dtype) or [dict-like](https://docs.python.org/3/glossary.html#term-mapping) of [`dtype`](https://numpy.org/doc/stable/reference/generated/numpy.dtype.html#numpy.dtype), *optional*) – dtype of the new array. If a dict-like, maps dtypes to
    variables. If omitted, it defaults to other.dtype.
  * **chunks** ([`int`](https://docs.python.org/3/builtins/functions.html#int), `"auto"`, [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple) of [`int`](https://docs.python.org/3/builtins/functions.html#int) or [mapping](https://docs.python.org/3/glossary.html#term-mapping) of `Hashable` to [`int`](https://docs.python.org/3/builtins/functions.html#int), *optional*) – Chunk sizes along each dimension, e.g., `5`, `"auto"`, `(5, 5)` or
    `{"x": 5, "y": 5}`.
  * **chunked_array_type** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str), *optional*) – Which chunked array type to coerce the underlying data array to.
    Defaults to ‘dask’ if installed, else whatever is registered via the ChunkManagerEnetryPoint system.
    Experimental API that should not be relied upon.
  * **from_array_kwargs** ([`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict), *optional*) – Additional keyword arguments passed on to the ChunkManagerEntrypoint.from_array method used to create
    chunked arrays, via whichever chunk manager is specified through the chunked_array_type kwarg.
    For example, with dask as the default chunked array type, this method would pass additional kwargs
    to [`dask.array.from_array()`](https://docs.dask.org/en/latest/generated/dask.array.from_array.html#dask.array.from_array). Experimental API that should not be relied upon.
* **Returns:**
  **out** (`same as object`) – New object with the same shape and type as other, with the data
  filled with fill_value. Coords will be copied from other.
  If other is based on dask, the new one will be as well, and will be
  split in the same chunks.

### Examples

<div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesShowIframe('32f44acd-6b28-45f6-93b2-4f694354beb3','26b7e7d0-5520-4121-b4b6-36ced8120bef','10ff28c3-717d-4e08-a414-1be774d2a855','../lite/tree/../notebooks/index.html?path=2955e413_2ec7_4fd3_96ce_e50ae4ae51c3.ipynb','None')">Try it in your browser!</button></div>
```pycon
>>> x = xr.DataArray(
...     np.arange(6).reshape(2, 3),
...     dims=["lat", "lon"],
...     coords={"lat": [1, 2], "lon": [0, 1, 2]},
... )
>>> x
<xarray.DataArray (lat: 2, lon: 3)> Size: 48B
array([[0, 1, 2],
       [3, 4, 5]])
Coordinates:
  * lat      (lat) int64 16B 1 2
  * lon      (lon) int64 24B 0 1 2
```

```pycon
>>> xr.full_like(x, 1)
<xarray.DataArray (lat: 2, lon: 3)> Size: 48B
array([[1, 1, 1],
       [1, 1, 1]])
Coordinates:
  * lat      (lat) int64 16B 1 2
  * lon      (lon) int64 24B 0 1 2
```

```pycon
>>> xr.full_like(x, 0.5)
<xarray.DataArray (lat: 2, lon: 3)> Size: 48B
array([[0, 0, 0],
       [0, 0, 0]])
Coordinates:
  * lat      (lat) int64 16B 1 2
  * lon      (lon) int64 24B 0 1 2
```

```pycon
>>> xr.full_like(x, 0.5, dtype=np.double)
<xarray.DataArray (lat: 2, lon: 3)> Size: 48B
array([[0.5, 0.5, 0.5],
       [0.5, 0.5, 0.5]])
Coordinates:
  * lat      (lat) int64 16B 1 2
  * lon      (lon) int64 24B 0 1 2
```

```pycon
>>> xr.full_like(x, np.nan, dtype=np.double)
<xarray.DataArray (lat: 2, lon: 3)> Size: 48B
array([[nan, nan, nan],
       [nan, nan, nan]])
Coordinates:
  * lat      (lat) int64 16B 1 2
  * lon      (lon) int64 24B 0 1 2
```

```pycon
>>> ds = xr.Dataset(
...     {"a": ("x", [3, 5, 2]), "b": ("x", [9, 1, 0])}, coords={"x": [2, 4, 6]}
... )
>>> ds
<xarray.Dataset> Size: 72B
Dimensions:  (x: 3)
Coordinates:
  * x        (x) int64 24B 2 4 6
Data variables:
    a        (x) int64 24B 3 5 2
    b        (x) int64 24B 9 1 0
>>> xr.full_like(ds, fill_value={"a": 1, "b": 2})
<xarray.Dataset> Size: 72B
Dimensions:  (x: 3)
Coordinates:
  * x        (x) int64 24B 2 4 6
Data variables:
    a        (x) int64 24B 1 1 1
    b        (x) int64 24B 2 2 2
>>> xr.full_like(ds, fill_value={"a": 1, "b": 2}, dtype={"a": bool, "b": float})
<xarray.Dataset> Size: 51B
Dimensions:  (x: 3)
Coordinates:
  * x        (x) int64 24B 2 4 6
Data variables:
    a        (x) bool 3B True True True
    b        (x) float64 24B 2.0 2.0 2.0
```

<div id="10ff28c3-717d-4e08-a414-1be774d2a855" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('32f44acd-6b28-45f6-93b2-4f694354beb3','10ff28c3-717d-4e08-a414-1be774d2a855')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('32f44acd-6b28-45f6-93b2-4f694354beb3','10ff28c3-717d-4e08-a414-1be774d2a855')">Open In Tab</button></div><div id="26b7e7d0-5520-4121-b4b6-36ced8120bef" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>

#### SEE ALSO
[`zeros_like`](xarray.zeros_like.html.md#xarray.zeros_like), [`ones_like`](xarray.ones_like.html.md#xarray.ones_like)
