# xarray.full_like

`xarray.``full_like`(other, fill_value, dtype: Union[numpy.dtype, str] = None)

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

  Parameters:

  - other (DataArray, Dataset, or Variable) – The reference object in input
  - fill_value (scalar) – Value to fill the new object with before returning it.
  - dtype (dtype, optional) – dtype of the new array. If omitted, it defaults to other.dtype.

  Returns: | out – 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.
  Return type: | same as object

  Examples

      >>> import numpy as np
      >>> import xarray as xr
      >>> 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)>
      array([[0, 1, 2],
             [3, 4, 5]])
      Coordinates:
      * lat      (lat) int64 1 2
      * lon      (lon) int64 0 1 2

      >>> xr.full_like(x, 1)
      <xarray.DataArray (lat: 2, lon: 3)>
      array([[1, 1, 1],
             [1, 1, 1]])
      Coordinates:
      * lat      (lat) int64 1 2
      * lon      (lon) int64 0 1 2

      >>> xr.full_like(x, 0.5)
      <xarray.DataArray (lat: 2, lon: 3)>
      array([[0, 0, 0],
             [0, 0, 0]])
      Coordinates:
      * lat      (lat) int64 1 2
      * lon      (lon) int64 0 1 2

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

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

  See also

  `zeros_like()`, `ones_like()`