issues: 1306457778
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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1306457778 | I_kwDOAMm_X85N3vay | 6791 | get_data or get_varibale method | 90008 | closed | 0 | 3 | 2022-07-15T20:24:31Z | 2023-04-29T03:40:01Z | 2023-04-29T03:40:01Z | CONTRIBUTOR | Is your feature request related to a problem?I often store a few scalars or arrays in xarray containers. However, when I want to optionally address their data the code I have to run ```python import xarray as xr dataset = xr.Dataset() my_variable = dataset.get('my_variable', None) if my_variable is not None: my_variable = my_variable.data else: my_variable = np.asarray(1.0) # the default value I actually want ``` Describe the solution you'd like```python import xarray as xr dataset = xr.Dataset() my_variable = dataset.get_data('my_variable', np.asarray(1.0)) ``` Describe alternatives you've consideredNo response Additional contextThank you! |
{
"url": "https://api.github.com/repos/pydata/xarray/issues/6791/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} |
completed | 13221727 | issue |