# 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('9d951c73-76d4-4490-b340-aca9ef0498be','da526dc2-e768-4757-b2a4-6fcc6bb48366','a5931f5b-2ed5-4974-b077-2482a0c226f9','../lite/tree/../notebooks/index.html?path=be896ff2_9b06_4e00_9919_d74049143d56.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="a5931f5b-2ed5-4974-b077-2482a0c226f9" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('9d951c73-76d4-4490-b340-aca9ef0498be','a5931f5b-2ed5-4974-b077-2482a0c226f9')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('9d951c73-76d4-4490-b340-aca9ef0498be','a5931f5b-2ed5-4974-b077-2482a0c226f9')">Open In Tab</button></div><div id="da526dc2-e768-4757-b2a4-6fcc6bb48366" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>
