code: def to_tsdata(
      df,
      column_id=None,
      column_kind=None,
      column_value=None,
      column_sort=None,
  ):
      """
      Wrap supported data formats as a TsData object, i.e. an iterable of individual time series.
  
      E.g. the DataFrame
  
          ====  ======  =========
            id  kind          val
          ====  ======  =========
             1  a       -0.21761
             1  a       -0.613667
             1  a       -2.07339
             2  b       -0.576254
             2  b       -1.21924
          ====  ======  =========
  
      into
  
          Iterable((1, 'a', pd.Series([-0.217610, -0.613667, -2.073386]),
           (2, 'b', pd.Series([-0.576254, -1.219238]))
  
      :param df: one of the supported input formats
      :type df: pd.DataFrame|dict|TsData
  
      :param column_id: The name of the id column to group by.
      :type column_id: str|None
  
      :param column_kind: The name of the column keeping record on the kind of the value.
      :type column_kind: str|None
  
      :param column_value: The name for the column keeping the value itself.
      :type column_value: str|None
  
      :param column_sort: The name for the column to sort on.
      :type column_sort: str|None
  
      :return: a data adapter
      :rtype: TsData
      """
      if isinstance(df, TsData):
          return df
  
      elif isinstance(df, pd.DataFrame):
          if column_kind is not None:
              return LongTsFrameAdapter(
                  df, column_id, column_kind, column_value, column_sort
              )
          else:
              if column_value is not None:
                  return WideTsFrameAdapter(
                      df, column_id, column_sort, [column_value]
                  )
              else:
                  return WideTsFrameAdapter(df, column_id, column_sort)
  
      elif isinstance(df, dict):
          return TsDictAdapter(df, column_id, column_value, column_sort)
  
      elif dd and isinstance(df, dd.DataFrame):
          return DaskTsAdapter(
              df, column_id, column_kind, column_value, column_sort
          )
  
      else:
          raise ValueError(
              "df must be a DataFrame or a dict of DataFrames. "
              "See https://tsfresh.readthedocs.io/en/latest/text/data_formats.html"
          )
  
imports: import itertools
  from collections import defaultdict, namedtuple
  from typing import Iterable, Sized
  import pandas
label_desc: Use image node_id 5 for calling a global function with example usage: to_tsdata(df, column_id, column_kind, column_value, column_sort) and returns: df, LongTsFrameAdapter, TsDictAdapter, WideTsFrameAdapter, WideTsFrameAdapter, DaskTsAdapter