code: def mean_by_group(values, group):
      """Compute the mean value by group
  
      Parameters
      ----------
      values : np.ndarray
          A 2 dimensional array. Rows indicate observations and columns indicate different variables.
      group : sequence
          A sequence that indicates to which group each observation belongs to. If `None`, then
          no group exists.
  
      Returns
      -------
      np.ndarray
          An array with the mean values for all the variables, per group, if there's a group.
          It's of shape (groups_n, variables_n).
      """
      if group is None:
          return np.mean(values, axis=0)
      levels = np.unique(group)
      means = np.zeros((len(levels), values.shape[1]))
      for i, level in enumerate(levels):
          means[i] = np.mean(values[group == level], axis=0)
      return means
  
file_path: bambi/bambi/transformations.py
imports: import numpy
  import pandas
  from formulae.transforms import register_stateful_transform
label_desc: Use image node_id 7 for calling a global function with example usage: mean_by_group(values, group) and returns: means, np