Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get a list with the variable names of my xarray.Dataset?

I am looking for a way of extracting a list of the data variable names (strings) from a xarray.DataSet object. I have used xr_object.data_vars and xr_object.data_vars.keys() but they don't seem to give anything usefull.

Also, the docs of xarray don't seem show that xarray has a built in method or attribute for getting something similar.

Anybody knows how to do so?

like image 625
Thomas Avatar asked Sep 13 '25 17:09

Thomas


1 Answers

Your question is a little ambigous. I guess you know that

xr_object.keys()

would give you a view of the dataset keys.

if you just need to put it to a list, then a list() function would do it ( at least after V0.11 ): (ds is the xr_object)

list(ds.keys())

and if you need dimensions too:

list(ds.coords)
like image 74
fenixnano Avatar answered Sep 17 '25 20:09

fenixnano