code: def ts_stats(Xt, y, fs=1.0, class_labels=None):
      """
      Generates some helpful statistics about the data X
  
      Parameters
      ----------
      X : array-like, shape [n_series, ...]
         Time series data and (optionally) contextual data
      y : array-like, shape [n_series]
          target data
      fs : float
          sampling frequency
      class_labels : list of strings, default None
          List of target class names
  
  
      Returns
      -------
      results : dict
          | Dictionary of relevant statistics for the time series data
          | results['total'] has stats for the whole data set
          | results['by_class'] has stats segragated by target class
  
      """
      check_ts_data(Xt)
      Xt, Xs = get_ts_data_parts(Xt)
  
      if Xs is not None:
          S = len(np.atleast_1d(Xs[0]))
      else:
          S = 0
  
      C = np.max(y) + 1  # number of classes
      if class_labels is None:
          class_labels = np.arange(C)
  
      N = len(Xt)
      if Xt[0].ndim > 1:
          D = Xt[0].shape[1]
      else:
          D = 1
  
      Ti = (
          np.array([Xt[i].shape[0] for i in range(N)], dtype=np.float64)
          / fs
      )
      ic = np.array([y == i for i in range(C)])
      Tic = [Ti[ic[i]] for i in range(C)]
  
      T = np.sum(Ti)
  
      total = {
          "n_series": N,
          "n_classes": C,
          "n_TS_vars": D,
          "n_context_vars": S,
          "Total_Time": T,
          "Series_Time_Mean": np.mean(Ti),
          "Series_Time_Std": np.std(Ti),
          "Series_Time_Range": (np.min(Ti), np.max(Ti)),
      }
  
      by_class = {
          "Class_labels": class_labels,
          "n_series": np.array([len(Tic[i]) for i in range(C)]),
          "Total_Time": np.array([np.sum(Tic[i]) for i in range(C)]),
          "Series_Time_Mean": np.array(
              [np.mean(Tic[i]) for i in range(C)]
          ),
          "Series_Time_Std": np.array(
              [np.std(Tic[i]) for i in range(C)]
          ),
          "Series_Time_Min": np.array(
              [np.min(Tic[i]) for i in range(C)]
          ),
          "Series_Time_Max": np.array(
              [np.max(Tic[i]) for i in range(C)]
          ),
      }
  
      results = {"total": total, "by_class": by_class}
  
      return results
  
file_path: seglearn/seglearn/util.py
imports: from pandas import DataFrame
  import numpy
  import warnings
  from seglearn.base import TS_Data
label_desc: Use image node_id 4 for calling a global function with example usage: ts_stats(Xt, y, fs, class_labels) and returns: results