adding attributes and metadata to a dataset using xarray
#import xarray
import xarray as xr
#open dataset
ds = xr.open_dataset(file_name.nc)
#add attributes and metadata in different ways
ds.attrs = {attribute name : attribute value}
ds.attrs[attribute name] = attribute value