If var is an xarray.DataArray, you can put it (along with attributes) into a new xarray.Dataset simply by writing ds[name_] = var. Or you can construct a new DataArray piece by piece with xarray.DataArray(var.data, var.coords, var.dims, var.attrs).