# xarray.DataArray.assign_attrs

#### DataArray.assign_attrs(\*args, \*\*kwargs)[[source]](https://github.com/pydata/xarray/blob/main/xarray/core/common.py#L674-L727)

Assign new attrs to this object.

Returns a new object equivalent to `self.attrs.update(*args, **kwargs)`.

* **Parameters:**
  * **\*args** – positional arguments passed into `attrs.update`.
  * **\*\*kwargs** – keyword arguments passed into `attrs.update`.

### Examples

<div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesShowIframe('8ec2e7a9-db87-4308-b9ec-2d7c740abd4b','b2919cc9-5a3c-4b57-8cb5-9fb7857abdb6','1fa47e80-3feb-4bd9-a0c5-ed835cf72c39','../lite/tree/../notebooks/index.html?path=ad0a1178_e296_4c7e_b952_581ed8e366eb.ipynb','None')">Try it in your browser!</button></div>
```pycon
>>> dataset = xr.Dataset({"temperature": [25, 30, 27]})
>>> dataset
<xarray.Dataset> Size: 24B
Dimensions:      (temperature: 3)
Coordinates:
  * temperature  (temperature) int64 24B 25 30 27
Data variables:
    *empty*
```

```pycon
>>> new_dataset = dataset.assign_attrs(
...     units="Celsius", description="Temperature data"
... )
>>> new_dataset
<xarray.Dataset> Size: 24B
Dimensions:      (temperature: 3)
Coordinates:
  * temperature  (temperature) int64 24B 25 30 27
Data variables:
    *empty*
Attributes:
    units:        Celsius
    description:  Temperature data
```

# Attributes of the new dataset

```pycon
>>> new_dataset.attrs
{'units': 'Celsius', 'description': 'Temperature data'}
```

<div id="1fa47e80-3feb-4bd9-a0c5-ed835cf72c39" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('8ec2e7a9-db87-4308-b9ec-2d7c740abd4b','1fa47e80-3feb-4bd9-a0c5-ed835cf72c39')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('8ec2e7a9-db87-4308-b9ec-2d7c740abd4b','1fa47e80-3feb-4bd9-a0c5-ed835cf72c39')">Open In Tab</button></div><div id="b2919cc9-5a3c-4b57-8cb5-9fb7857abdb6" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>
* **Returns:**
  **assigned** (`same type as caller`) – A new object with the new attrs in addition to the existing data.

#### SEE ALSO
[`Dataset.assign`](xarray.Dataset.assign.html.md#xarray.Dataset.assign)
