# xarray.NamedArray.broadcast_to

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

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('17c49a7d-6a4e-4e24-83eb-258131708e82','bf3e8544-9ff2-40a6-88ad-d8bf3d63605a','1f2830b1-5eb1-4ceb-9aa9-449cbf303518','../lite/tree/../notebooks/index.html?path=642b857f_2159_40aa_a513_707e115b9150.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="1f2830b1-5eb1-4ceb-9aa9-449cbf303518" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('17c49a7d-6a4e-4e24-83eb-258131708e82','1f2830b1-5eb1-4ceb-9aa9-449cbf303518')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('17c49a7d-6a4e-4e24-83eb-258131708e82','1f2830b1-5eb1-4ceb-9aa9-449cbf303518')">Open In Tab</button></div><div id="bf3e8544-9ff2-40a6-88ad-d8bf3d63605a" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>
