Answers for "how to select variables in a dataset using xarray"

0

how to select variables in a dataset using xarray

#import xarray
import xarray as xr

#open the dataset
ds = xr.open_dataset(file_name.nc)

#var_name in the following table is to be entered as a string

selection         |    syntax                     |    returns
--------------------------------------------------------------
single variable   | ds[var_name]                  | DataArray
--------------------------------------------------------------
single variable   | ds[[var_name]]                | Dataset
--------------------------------------------------------------
multiple variable | ds[[var_name1, var_name2...]] | Dataset
Posted by: Guest on January-24-2021

Code answers related to "how to select variables in a dataset using xarray"

Python Answers by Framework

Browse Popular Code Answers by Language