code: def apply_func_array(
      feature, metrics, apply_to_df, assign_to_df, apply_funcs, same_key
  ):
      """Apply list of functions to dataframe
  
      Split off for parallelization reasons
  
      :param str feature: feature currently looping over
      :param list metrics: list of selected metrics to apply functions to
      :param apply_to_df: pandas data frame that function in arr is applied to
      :param assign_to_df: pandas data frame the output of function is assigned to
      :param apply_funcs: list of functions to apply to
      :param same_key: if True, merge apply_to_df and assign_to_df before returning assign_to_df
      :return: union of feature and assign_to_df
      """
      if not isinstance(apply_to_df, pd.DataFrame):
          raise TypeError(
              f'apply_to_df of feature "{feature}" is not a pandas dataframe.'
          )
  
      if same_key or (
          len(assign_to_df.index) == 0
          and len(assign_to_df.columns) == 0
      ):
          assign_to_df = pd.DataFrame(index=apply_to_df.index)
  
      for arr in apply_funcs:
          obj = apply_func(feature, metrics, apply_to_df, arr)
          if len(obj) == 0:
              # no metrics were found in apply_to_df
              continue
          for new_metric, o in obj.items():
              if isinstance(o, pd.Series):
                  if len(assign_to_df.index) == len(o) and all(
                      assign_to_df.index == o.index
                  ):
                      assign_to_df[new_metric] = o
                  else:
                      warnings.warn(
                          f"{feature}:{new_metric}: df_out and object have inconsistent lengths."
                      )
              else:
                  # o is number or object, assign to every element of new column
                  assign_to_df[new_metric] = [o] * len(
                      assign_to_df.index
                  )
      if same_key:
          assign_to_df = pd.concat([apply_to_df, assign_to_df], axis=1)
      return feature, assign_to_df
  
file_path: popmon/popmon/analysis/apply_func.py
imports: from __future__ import annotations
  import warnings
  import numpy
  import pandas
  from popmon.base import Module
  from popmon.utils import parallel
label_desc: Use image node_id 1 for calling a global function with example usage: apply_func_array(feature, metrics, apply_to_df, assign_to_df, apply_funcs, same_key) and returns: feature,  assign_to_df