code: def _aggregate_dataset(self, obj, xcoords, ycoords):
          
          dim_labels = obj.dimensions(label=True)
          vdims = obj.dimensions()[2:]
          xdim, ydim = dim_labels[:2]
          shape = (len(ycoords), len(xcoords))
          nsamples = np.product(shape)
          grid_data = {xdim: xcoords, ydim: ycoords}
  
          ys, xs = cartesian_product([ycoords, xcoords], copy=True)
          data = {xdim: xs, ydim: ys}
          for vdim in vdims:
              values = np.empty(nsamples)
              values[:] = np.NaN
              data[vdim.name] = values
          dtype = default_datatype
          dense_data = Dataset(data, kdims=obj.kdims, vdims=obj.vdims, datatype=[dtype])
          concat_data = obj.interface.concatenate([dense_data, obj], datatype=dtype)
          reindexed = concat_data.reindex([xdim, ydim], vdims)
          if not reindexed:
              agg = reindexed
          elif pd:
              df = PandasInterface.as_dframe(reindexed)
              df = df.groupby([xdim, ydim], sort=False).first().reset_index()
              agg = reindexed.clone(df)
          else:
              agg = reindexed.aggregate([xdim, ydim], reduce_fn)
  
          # Convert data to a gridded dataset
          for vdim in vdims:
              grid_data[vdim.name] = agg.dimension_values(vdim).reshape(shape)
          return agg.clone(grid_data, kdims=[xdim, ydim], vdims=vdims,
                           datatype=self.p.datatype)
docs: Generates a gridded Dataset from a column-based dataset and
          lists of xcoords and ycoords