code: def build_data(data, cfg):
      index, col, agg = (cfg.get(p) for p in ["index", "col", "agg"])
      if agg:
          return getattr(data.groupby(index)[col], agg)()
      if data[index].duplicated().any():
          raise ValueError(
              "It appears there is duplicates in your index, please specify an aggregation!"
          )
      return data.set_index(index)[col]
  
imports: import pandas
  from six import PY3
  from statsmodels.tsa.filters.bk_filter import bkfilter
  from statsmodels.tsa.filters.cf_filter import cffilter
  from statsmodels.tsa.filters.hp_filter import hpfilter
  from statsmodels.tsa.seasonal import seasonal_decompose
  import dtale.global_state
  from dtale.query import run_query
  from dtale.charts.utils import build_base_chart
label_desc: Use image node_id 1 for calling a global function with example usage: build_data(data, cfg) and returns: data, getattr