# xarray.NamedArray.expand_dims

#### NamedArray.expand_dims(dim=Default.token)[[source]](https://github.com/pydata/xarray/blob/main/xarray/namedarray/core.py#L1269-L1308)

Expand the dimensions of the NamedArray.

This method adds new dimensions to the object. The new dimensions are added at the beginning of the array.

* **Parameters:**
  **dim** (`Hashable`, *optional*) – Dimension name to expand the array to. This dimension will be added at the beginning of the array.
* **Returns:**
  `NamedArray` – A new NamedArray with expanded dimensions.

### Examples

<div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesShowIframe('1ed1665c-7988-4b84-a4ba-3cb1f0afe52d','8ad77678-af2e-4e84-aa6b-17019afbecb6','c8b39f10-5a47-4cef-998d-f441aeb4927e','../lite/tree/../notebooks/index.html?path=3e48212b_063e_416b_b769_1e5a0f464790.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)
```

# expand dimensions by specifying a new dimension name
>>> expanded = array.expand_dims(dim=”z”)
>>> expanded.dims
(‘z’, ‘x’, ‘y’)

<div id="c8b39f10-5a47-4cef-998d-f441aeb4927e" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('1ed1665c-7988-4b84-a4ba-3cb1f0afe52d','c8b39f10-5a47-4cef-998d-f441aeb4927e')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('1ed1665c-7988-4b84-a4ba-3cb1f0afe52d','c8b39f10-5a47-4cef-998d-f441aeb4927e')">Open In Tab</button></div><div id="8ad77678-af2e-4e84-aa6b-17019afbecb6" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>
