code: def aggregate_profiles(
      all_profiles,
      mean_prediction,
      type,
      groups,
      center,
      span,
      verbose=True,
  ):
      if type == "partial":
          aggregated_profiles = (
              all_profiles.groupby(
                  ["_vname_", "_label_", "_x_"] + groups, sort=False
              )["_yhat_"]
              .mean()
              .reset_index()
          )
  
      else:
          # split all_profiles into groups
          tqdm.pandas(
              desc="Calculating accumulated dependency",
              disable=not verbose,
          ) if type == "accumulated" else tqdm.pandas(
              desc="Calculating conditional dependency",
              disable=not verbose,
          )
          aggregated_profiles = (
              all_profiles.loc[
                  :,
                  [
                      "_vname_",
                      "_label_",
                      "_x_",
                      "_yhat_",
                      "_ids_",
                      "_original_",
                  ]
                  + groups,
              ]
              .groupby(["_vname_", "_label_"])
              .progress_apply(
                  lambda split_profile: split_over_variables_and_labels(
                      split_profile.copy(deep=True), type, groups, span
                  )
              )
              .reset_index(level=[0, 1])
          )  # remove level_2
          # deepcopy due to https://github.com/ModelOriented/DALEX/issues/278
  
      aggregated_profiles.loc[:, "_ids_"] = 0
  
      if type == "accumulated" and center:
          aggregated_profiles.loc[:, "_yhat_"] = (
              aggregated_profiles.loc[:, "_yhat_"]
              - aggregated_profiles.loc[:, "_yhat_"].mean()
              + mean_prediction
          )
  
      # postprocessing
      if len(groups) != 0:
          aggregated_profiles["_groups_"] = aggregated_profiles.loc[
              :, groups
          ].apply(lambda row: "_".join(row.astype(str)), axis=1)
          aggregated_profiles.drop(columns=groups, inplace=True)
  
          aggregated_profiles.loc[
              :, "_label_"
          ] = aggregated_profiles.loc[:, ["_label_", "_groups_"]].apply(
              lambda row: "_".join(row), axis=1
          )
  
      return aggregated_profiles
  
file_path: DALEX/python/dalex/dalex/model_explanations/_aggregated_profiles/utils.py
imports: import numpy
  import pandas
  from tqdm import tqdm
label_desc: Use image node_id 1 for calling a global function with example usage: aggregate_profiles(all_profiles, mean_prediction, type, groups, center, span, verbose) and returns: aggregated_profiles