| add a DataArray to my dataset as a new variable |
my_dataset[varname] = my_dataArray or Dataset.assign() (see also Dictionary like methods) |
| add variables from other datasets to my dataset |
Dataset.merge() |
| add a new dimension and/or coordinate |
DataArray.expand_dims(), Dataset.expand_dims() |
| add a new coordinate variable |
DataArray.assign_coords() |
| change a data variable to a coordinate variable |
Dataset.set_coords() |
| change the order of dimensions |
DataArray.transpose(), Dataset.transpose() |
| remove a variable from my object |
Dataset.drop_vars(), DataArray.drop_vars() |
| remove dimensions of length 1 or 0 |
DataArray.squeeze(), Dataset.squeeze() |
| remove all variables with a particular dimension |
Dataset.drop_dims() |
| convert non-dimension coordinates to data variables or remove them |
DataArray.reset_coords(), Dataset.reset_coords() |
| rename a variable, dimension or coordinate |
Dataset.rename(), DataArray.rename(), Dataset.rename_vars(), Dataset.rename_dims(), |
| convert a DataArray to Dataset or vice versa |
DataArray.to_dataset(), Dataset.to_array() |
| extract the underlying array (e.g. numpy or Dask arrays) |
DataArray.data |
| convert to and extract the underlying numpy array |
DataArray.values |
| find out if my xarray object is wrapping a Dask Array |
dask.is_dask_collection() |
| know how much memory my object requires |
DataArray.nbytes, Dataset.nbytes |
| convert a possibly irregularly sampled timeseries to a regularly sampled timeseries |
DataArray.resample(), Dataset.resample() (see Resampling and grouped operations for more) |
| apply a function on all data variables in a Dataset |
Dataset.map() |
| write xarray objects with complex values to a netCDF file |
Dataset.to_netcdf(), DataArray.to_netcdf() specifying engine="h5netcdf", invalid_netcdf=True |
| make xarray objects look like other xarray objects |
ones_like(), zeros_like(), full_like(), Dataset.reindex_like(), Dataset.interp_like(), Dataset.broadcast_like(), DataArray.reindex_like(), DataArray.interp_like(), DataArray.broadcast_like() |
| replace NaNs with other values |
Dataset.fillna(), Dataset.ffill(), Dataset.bfill(), Dataset.interpolate_na(), DataArray.fillna(), DataArray.ffill(), DataArray.bfill(), DataArray.interpolate_na() |
| extract the year, month, day or similar from a DataArray of time values |
obj.dt.month for example where obj is a DataArray containing datetime64 or cftime values. See Datetime components for more. |
| round off time values to a specified frequency |
obj.dt.ceil, obj.dt.floor, obj.dt.round. See Datetime components for more. |
make a mask that is True where an object contains any of the values in a array |
Dataset.isin(), DataArray.isin() |