issues: 1051241489
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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1051241489 | I_kwDOAMm_X84-qKwR | 5976 | Should str.format() work on xarray scalars? | 10050469 | closed | 0 | 3 | 2021-11-11T18:15:59Z | 2022-07-25T20:01:29Z | 2022-07-25T20:01:29Z | MEMBER | Consider:
Which outputs: ``` <xarray.DataArray ()> array(1) TypeError Traceback (most recent call last) <ipython-input-36-9cd7dc76455b> in <module> 1 da = xr.DataArray([1, 2, 3]) 2 print(f'{da[0]}') ----> 3 print(f'{da[0]:d}') TypeError: unsupported format string passed to DataArray.format ``` And the numpy equivalent:
I always found the xarray scalar output to be a bit unfriendly for beginners. In my classes very often scalars are the last output of a computation, and the fact that we can't format the relatively verbose xarray output without resulting to the Is there a way to get |
{ "url": "https://api.github.com/repos/pydata/xarray/issues/5976/reactions", "total_count": 3, "+1": 3, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
completed | 13221727 | issue |