code: def labelmeanfilter_str(ys, x):
      # works also for string labels in ys, but requires 1D
      # from mailing list scipy-user 2009-02-11
      unil, unilinv = np.unique(
          ys, return_index=False, return_inverse=True
      )
      labelmeans = np.array(
          ndimage.mean(
              x, labels=unilinv, index=np.arange(np.max(unil) + 1)
          )
      )
      arr3 = labelmeans[unilinv]
      return arr3
  
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 3 for calling a global function with example usage: labelmeanfilter_str(ys, x) and returns: arr3