code: def labelmeanfilter(y, x):
      # requires integer labels
      # from mailing list scipy-user 2009-02-11
      labelsunique = np.arange(np.max(y) + 1)
      labelmeans = np.array(
          ndimage.mean(x, labels=y, index=labelsunique)
      )
      # returns label means for each original observation
      return labelmeans[y]
  
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 1 for calling a global function with example usage: labelmeanfilter(y, x) and returns: labelmeans