Xarray转台:TypeError:不可用的类型:' list'
我正在尝试重新排列以下数据集的尺寸,
X
xarray.Dataset
Dimensions:
lon: 720lat: 360sector: 8time: 240
Coordinates:
lon
(lon)
float64
-179.8 -179.2 ... 179.2 179.8
lat
(lat)
float64
-89.75 -89.25 ... 89.25 89.75
sector
(sector)
int32
0 1 2 3 4 5 6 7
time
(time)
object
2000-01-16 00:00:00 ... 2019-12-...
Data variables:
CO_em_anthro
(time, sector, lat, lon)
float32
0.0 0.0 0.0 0.0 ... 0.0 0.0 0.0 0.0
Attributes: (33)
但
X.transpose(['lat','lon','sector','time'])
在0.20.1版本中,我收到以下错误
File /nbhome/f1p/miniconda3/envs/f1p_gfdl/lib/python3.9/site-packages/xarray/core/utils.py:879, in drop_missing_dims(supplied_dims, dims, missing_dims)
868 """Depending on the setting of missing_dims, drop any dimensions from supplied_dims that
869 are not present in dims.
870
(...)
875 missing_dims : {"raise", "warn", "ignore"}
876 """
878 if missing_dims == "raise":
--> 879 supplied_dims_set = {val for val in supplied_dims if val is not ...}
880 invalid = supplied_dims_set - set(dims)
881 if invalid:
File /nbhome/f1p/miniconda3/envs/f1p_gfdl/lib/python3.9/site-packages/xarray/core/utils.py:879, in <setcomp>(.0)
868 """Depending on the setting of missing_dims, drop any dimensions from supplied_dims that
869 are not present in dims.
870
(...)
875 missing_dims : {"raise", "warn", "ignore"}
876 """
878 if missing_dims == "raise":
--> 879 supplied_dims_set = {val for val in supplied_dims if val is not ...}
880 invalid = supplied_dims_set - set(dims)
881 if invalid:
TypeError: unhashable type: 'list'
调用transpose确实可以在没有尺寸名称的情况下工作。 我不确定如何解决此问题。谢谢
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Xarray的转置接受目标维度为多个参数,而不是尺寸列表。
请参阅。
您需要将代码更改为:
Xarray’s transpose accepts the target dimensions as multiple arguments, not a list of dimensions.
See the
*args
in the transpose docs.You need to change your code to: