code: def var(self, values, axis=0, weights=None, dtype=None):
          
          values = np.asarray(values)
          unique, mean = self.mean(values, axis, weights, dtype)
          err = values - mean.take(self.inverse, axis)
  
          if weights is None:
              shape = [1] * values.ndim
              shape[axis] = self.groups
              group_weights = self.count.reshape(shape)
              var = self.reduce(err ** 2, axis=axis, dtype=dtype)
          else:
              weights = np.asarray(weights)
              group_weights = self.reduce(weights, axis=axis, dtype=dtype)
              var = self.reduce(weights * err ** 2, axis=axis, dtype=dtype)
  
          return unique, var / group_weights
docs: compute the variance over each group
  
          Parameters
          ----------
          values : array_like, [keys, ...]
              values to take variance of per group
          axis : int, optional
              alternative reduction axis for values
  
          Returns
          -------
          unique: ndarray, [groups]
              unique keys
          reduced : ndarray, [groups, ...]
              value array, reduced over groups