简体   繁体   中英

How to transform a set of xarray dataset variables into a single variable with additional dimension

I have the below xarray Dataset. Now, I'd like to combine Fender_1, Fender_2, and Fender_3 variables into a single variable called "data" with the dimension "fender_name". Such that I can simply call the variable "data" and select which fender I want using data.sel(fender_name = ...)

How can I achieve this?

xarray 数据集

一种方法是使用Dataset.to_array

data = ds[["Fender_1", "Fender_2", "Fender_3"]].to_array(dim="fender_name")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM