code: def mode(self, values, weights=None):
          
          if weights is None:
              unique, weights = npi.count((self.index.sorted_group_rank_per_key, values))
          else:
              unique, weights = npi.group_by((self.index.sorted_group_rank_per_key, values)).sum(weights)
  
          x, bin = npi.group_by(unique[0]).argmax(weights)
          return x, unique[1][bin]
docs: compute the mode within each group.
  
          Parameters
          ----------
          values : array_like, [keys, ...]
              values to compute the mode of per group
          weights : array_like, [keys], float, optional
              optional weight associated with each entry in values
  
          Returns
          -------
          unique: ndarray, [groups]
              unique keys
          reduced : ndarray, [groups, ...]
              value array, reduced over groups