# xarray.DataArray.broadcast_like

#### DataArray.broadcast_like(other, , exclude=None)[[source]](https://github.com/pydata/xarray/blob/main/xarray/core/dataarray.py#L2001-L2076)

Broadcast this DataArray against another Dataset or DataArray.

This is equivalent to xr.broadcast(other, self)[1]

xarray objects are broadcast against each other in arithmetic
operations, so this method is not be necessary for most uses.

If no change is needed, the input data is returned to the output
without being copied.

If new coords are added by the broadcast, their values are
NaN filled.

* **Parameters:**
  * **other** ([`Dataset`](xarray.Dataset.html.md#xarray.Dataset) or [`DataArray`](xarray.DataArray.html.md#xarray.DataArray)) – Object against which to broadcast this array.
  * **exclude** ([iterable](https://docs.python.org/3/glossary.html#term-iterable) of `Hashable`, *optional*) – Dimensions that must not be broadcasted
* **Returns:**
  **new_da** ([`DataArray`](xarray.DataArray.html.md#xarray.DataArray)) – The caller broadcasted against `other`.

### Examples

<div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesShowIframe('5fadf51a-4f4b-4cbb-a01b-a81d5cb7f15b','bbf7294c-1179-42d7-b422-139281327d06','13a544bf-b8ee-421a-ad60-618beba37814','../lite/tree/../notebooks/index.html?path=a1570ac3_7491_4bb5_a2dd_5072bd3d71ba.ipynb','None')">Try it in your browser!</button></div>
```pycon
>>> arr1 = xr.DataArray(
...     np.random.randn(2, 3),
...     dims=("x", "y"),
...     coords={"x": ["a", "b"], "y": ["a", "b", "c"]},
... )
>>> arr2 = xr.DataArray(
...     np.random.randn(3, 2),
...     dims=("x", "y"),
...     coords={"x": ["a", "b", "c"], "y": ["a", "b"]},
... )
>>> arr1
<xarray.DataArray (x: 2, y: 3)> Size: 48B
array([[ 1.76405235,  0.40015721,  0.97873798],
       [ 2.2408932 ,  1.86755799, -0.97727788]])
Coordinates:
  * x        (x) <U1 8B 'a' 'b'
  * y        (y) <U1 12B 'a' 'b' 'c'
>>> arr2
<xarray.DataArray (x: 3, y: 2)> Size: 48B
array([[ 0.95008842, -0.15135721],
       [-0.10321885,  0.4105985 ],
       [ 0.14404357,  1.45427351]])
Coordinates:
  * x        (x) <U1 12B 'a' 'b' 'c'
  * y        (y) <U1 8B 'a' 'b'
>>> arr1.broadcast_like(arr2)
<xarray.DataArray (x: 3, y: 3)> Size: 72B
array([[ 1.76405235,  0.40015721,  0.97873798],
       [ 2.2408932 ,  1.86755799, -0.97727788],
       [        nan,         nan,         nan]])
Coordinates:
  * x        (x) <U1 12B 'a' 'b' 'c'
  * y        (y) <U1 12B 'a' 'b' 'c'
```

<div id="13a544bf-b8ee-421a-ad60-618beba37814" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('5fadf51a-4f4b-4cbb-a01b-a81d5cb7f15b','13a544bf-b8ee-421a-ad60-618beba37814')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('5fadf51a-4f4b-4cbb-a01b-a81d5cb7f15b','13a544bf-b8ee-421a-ad60-618beba37814')">Open In Tab</button></div><div id="bbf7294c-1179-42d7-b422-139281327d06" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>
