code: def predict_expectation(self, X):
          
          index = _get_index(X)
          t = self._index
          return pd.DataFrame(trapz(self.predict_survival_function(X)[index].values.T, t), index=index)
docs: Compute the expected lifetime, E[T], using covariates X.
  
          Parameters
          ----------
          X: a (n,d) covariate numpy array or DataFrame
              If a DataFrame, columns
              can be in any order. If a numpy array, columns must be in the
              same order as the training data.
  
          Returns the expected lifetimes for the individuals