code: def assemble_data(data_list):
      """Build a data dictionary out of a list of entries and data dicts
  
      Given a list named tuples of dictionaries, :func:`assemble_data`
      returns a nested ordered dictionary with data keys as outer keys and
      tuple names as inner keys. The returned dictionary can be printed in
      tabular format by :func:`assemble_table`.
  
      .. seealso::
          :class:`Data`, :func:`assemble_table`
  
      Examples
      --------
      >>> from mlens.metrics import assemble_data, assemble_table
      >>> d = [('row-idx-1.row-idx-2.a.b', {'column-1': 0.1, 'column-2': 0.1})]
      >>> print(assemble_table(assemble_data(d)))
                              column-2-m  column-2-s  column-1-m  column-1-s
      row-idx-1  row-idx-2          0.10        0.00        0.10        0.00
      """
      data = _dict()
      tmp = _dict()
  
      partitions = _get_partitions(data_list)
  
      # Collect scores per preprocessing case and estimator(s)
      for name, data_dict in data_list:
          if not data_dict:
              continue
  
          prefix, name = _split(name, "/", a_s="/")
  
          # Names are either est.i.j or case.est.i.j
          splitted = name.split(".")
          if partitions:
              name = tuple(splitted[:-1])
  
              if len(name) == 3:
                  name = "%s.%s--%s" % name
              else:
                  name = "%s--%s" % name
          else:
              name = ".".join(splitted[:-2])
  
          name = "%s%s" % (prefix, name)
  
          if name not in tmp:
              # Set up data struct for name
              tmp[name] = _dict()
              for k in data_dict.keys():
                  tmp[name][k] = list()
                  if "%s-m" % k not in data:
                      data["%s-m" % k] = _dict()
                      data["%s-s" % k] = _dict()
                  data["%s-m" % k][name] = list()
                  data["%s-s" % k][name] = list()
  
          # collect all data dicts belonging to name
          for k, v in data_dict.items():
              tmp[name][k].append(v)
  
      # Aggregate to get mean and std
      for name, data_dict in tmp.items():
          for k, v in data_dict.items():
              if not v:
                  continue
              try:
                  # Purge None values from the main est due to no predict times
                  v = [i for i in v if i is not None]
                  if v:
                      data["%s-m" % k][name] = np.mean(v)
                      data["%s-s" % k][name] = np.std(v)
              except Exception as exc:
                  warnings.warn(
                      "Aggregating data for %s failed. Raw data:\n%r\n"
                      "Details: %r" % (k, v, exc),
                      MetricWarning,
                  )
  
      # Check if there are empty columns
      discard = list()
      for key, data_dict in data.items():
          empty = True
          for val in data_dict.values():
              if val or val == 0:
                  empty = False
          if empty:
              discard.append(key)
      for key in discard:
          data.pop(key)
      return data
  
file_path: mlens/mlens/metrics/utils.py
imports: from __future__ import division
  import warnings
  import numpy
  from ..utils.exceptions import MetricWarning
label_desc: Use image node_id 5 for calling a global function with example usage: assemble_data(data_list) and returns: data