issues: 313010564
This data as json
id | node_id | number | title | user | state | locked | assignee | milestone | comments | created_at | updated_at | closed_at | author_association | active_lock_reason | draft | pull_request | body | reactions | performed_via_github_app | state_reason | repo | type |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
313010564 | MDU6SXNzdWUzMTMwMTA1NjQ= | 2049 | Keeping attributes when using DataArray.astype | 4180033 | closed | 0 | 5 | 2018-04-10T17:02:18Z | 2020-08-19T20:34:35Z | 2020-08-19T20:34:35Z | NONE | Hi all, I was wondering whether there is an easier way to keep the attributes when using the DataArray.astype method? ```python import xarray as xr DataArray with attributesda = xr.DataArray( [[0, 1, 2], [0, 1, 2]], attrs={"attr1": "value1"} ) the attributes are not passed over to new_danew_da = da.astype(float) I have to set the attributes by myselfnew_da.attrs = da.attrs.copy() ``` This is just one extra-line, but I have to keep track of the old DataArray and it may become unhandy if I do many astype calls. Any hints? Output of
|
{ "url": "https://api.github.com/repos/pydata/xarray/issues/2049/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
completed | 13221727 | issue |