code: def to_array(self, dim='variable', name=None):
          
          from .dataarray import DataArray
  
          data_vars = [self.variables[k] for k in self.data_vars]
          broadcast_vars = broadcast_variables(*data_vars)
          data = duck_array_ops.stack([b.data for b in broadcast_vars], axis=0)
  
          coords = dict(self.coords)
          coords[dim] = list(self.data_vars)
  
          dims = (dim,) + broadcast_vars[0].dims
  
          return DataArray(data, coords, dims, attrs=self.attrs, name=name)
docs: Convert this dataset into an xarray.DataArray
  
          The data variables of this dataset will be broadcast against each other
          and stacked along the first axis of the new array. All coordinates of
          this dataset will remain coordinates.
  
          Parameters
          ----------
          dim : str, optional
              Name of the new dimension.
          name : str, optional
              Name of the new data array.
  
          Returns
          -------
          array : xarray.DataArray