# xarray.NamedArray.expand_dims

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

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('392a9d25-8da6-4db1-988c-b4cef5887bf1','224336f9-59d3-412d-9280-d01b95af3b22','289f28a3-9fc9-4b33-a9f7-a9f4da70f284','../lite/tree/../notebooks/index.html?path=94c4f2aa_0dbc_4b50_9cbd_8cbefc379495.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="289f28a3-9fc9-4b33-a9f7-a9f4da70f284" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('392a9d25-8da6-4db1-988c-b4cef5887bf1','289f28a3-9fc9-4b33-a9f7-a9f4da70f284')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('392a9d25-8da6-4db1-988c-b4cef5887bf1','289f28a3-9fc9-4b33-a9f7-a9f4da70f284')">Open In Tab</button></div><div id="224336f9-59d3-412d-9280-d01b95af3b22" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>
