# xarray.NamedArray.broadcast_to

#### NamedArray.broadcast_to(dim=None, \*\*dim_kwargs)[[source]](https://github.com/pydata/xarray/blob/main/xarray/namedarray/core.py#L1177-L1233)

Broadcast the NamedArray to a new shape. New dimensions are not allowed.

This method allows for the expansion of the array’s dimensions to a specified shape.
It handles both positional and keyword arguments for specifying the dimensions to broadcast.
An error is raised if new dimensions are attempted to be added.

* **Parameters:**
  * **dim** ([`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict), [`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [sequence](https://docs.python.org/3/glossary.html#term-sequence) of [`str`](https://docs.python.org/3/builtins/stdtypes.html#str), *optional*) – Dimensions to broadcast the array to. If a dict, keys are dimension names and values are the new sizes.
    If a string or sequence of strings, existing dimensions are matched with a size of 1.
  * **\*\*dim_kwargs** (`Any`) – Additional dimensions specified as keyword arguments. Each keyword argument specifies the name of an existing dimension and its size.
* **Returns:**
  `NamedArray` – A new NamedArray with the broadcasted dimensions.

### Examples

<div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesShowIframe('d7e4b24b-ec49-4552-bbc0-dbb7feda5f03','38db9d9e-cec4-4f2d-bc36-d869414df60c','c04773c7-ed87-4d74-9b0f-ac7e85163634','../lite/tree/../notebooks/index.html?path=468b0417_cf8d_4a8d_a3ff_bb068a66a730.ipynb','None')">Try it in your browser!</button></div>
```pycon
>>> data = np.asarray([[1.0, 2.0], [3.0, 4.0]])
>>> array = xr.NamedArray(("x", "y"), data)
>>> array.sizes
{'x': 2, 'y': 2}
```

```pycon
>>> broadcasted = array.broadcast_to(x=2, y=2)
>>> broadcasted.sizes
{'x': 2, 'y': 2}
```

<div id="c04773c7-ed87-4d74-9b0f-ac7e85163634" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('d7e4b24b-ec49-4552-bbc0-dbb7feda5f03','c04773c7-ed87-4d74-9b0f-ac7e85163634')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('d7e4b24b-ec49-4552-bbc0-dbb7feda5f03','c04773c7-ed87-4d74-9b0f-ac7e85163634')">Open In Tab</button></div><div id="38db9d9e-cec4-4f2d-bc36-d869414df60c" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>
