issue_comments: 1293975333
This data as json
html_url | issue_url | id | node_id | user | created_at | updated_at | author_association | body | reactions | performed_via_github_app | issue |
---|---|---|---|---|---|---|---|---|---|---|---|
https://github.com/pydata/xarray/issues/7211#issuecomment-1293975333 | https://api.github.com/repos/pydata/xarray/issues/7211 | 1293975333 | IC_kwDOAMm_X85NIH8l | 35968931 | 2022-10-27T19:33:55Z | 2022-10-27T19:40:19Z | MEMBER | Hi @airton-neto - here is a much shorter example that reproduces the same error ```python url = 'https://rda.ucar.edu/thredds/dodsC/files/g/ds084.1/2022/20220201/gfs.0p25.2022020100.f000.grib2' dataset = xr.open_dataset(url, cache=True, engine="netcdf4")
variables = list(['u-component_of_wind_height_above_ground']) # <--- This way it runsvariables = frozenlist(['u-component_of_wind_height_above_ground']) dataset[variables] ``` ```pythonKeyError Traceback (most recent call last) File ~/miniconda3/envs/py39/lib/python3.9/site-packages/xarray/core/dataset.py:1317, in Dataset._construct_dataarray(self, name) 1316 try: -> 1317 variable = self._variables[name] 1318 except KeyError: KeyError: ['u-component_of_wind_height_above_ground'] During handling of the above exception, another exception occurred: KeyError Traceback (most recent call last) Input In [43], in <cell line: 1>() ----> 1 dataset[variables] File ~/miniconda3/envs/py39/lib/python3.9/site-packages/xarray/core/dataset.py:1410, in Dataset.getitem(self, key) 1408 return self.isel(**key) 1409 if utils.hashable(key): -> 1410 return self._construct_dataarray(key) 1411 if utils.iterable_of_hashable(key): 1412 return self._copy_listed(key) File ~/miniconda3/envs/py39/lib/python3.9/site-packages/xarray/core/dataset.py:1319, in Dataset.construct_dataarray(self, name) 1317 variable = self._variables[name] 1318 except KeyError: -> 1319 , name, variable = _get_virtual_variable(self._variables, name, self.dims) 1321 needed_dims = set(variable.dims) 1323 coords: dict[Hashable, Variable] = {} File ~/miniconda3/envs/py39/lib/python3.9/site-packages/xarray/core/dataset.py:171, in _get_virtual_variable(variables, key, dim_sizes) 168 return key, key, variable 170 if not isinstance(key, str): --> 171 raise KeyError(key) 173 split_key = key.split(".", 1) 174 if len(split_key) != 2: KeyError: ['u-component_of_wind_height_above_ground'] ``` I'm not immediately sure why the elements of the list are not properly extracted, but the Having said that if you want to submit a PR which fixes this bug (and doesn't require special-casing dagster somehow) then that would be welcome too! |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
1422460071 |