code: def groupsstats_1d(y, x, labelsunique):
      """use ndimage to get fast mean and variance"""
      labelmeans = np.array(
          ndimage.mean(x, labels=y, index=labelsunique)
      )
      labelvars = np.array(ndimage.var(x, labels=y, index=labelsunique))
      return labelmeans, labelvars
  
file_path: statsmodels/statsmodels/sandbox/regression/try_catdata.py
imports: from statsmodels.compat.python import lrange
  import numpy
  from scipy import ndimage
label_desc: Use image node_id 6 for calling a global function with example usage: groupsstats_1d(y, x, labelsunique) and returns: labelmeans,  labelvars