code: def write_dataframe_to_tsfile(
      data,
      path,
      problem_name="sample_data",
      class_label=None,
      class_value_list=None,
      equal_length=False,
      series_length=-1,
      missing_values="NaN",
      comment=None,
      fold="",
  ):
      """Output a dataset in dataframe format to .ts file.
  
      Parameters
      ----------
      data: pandas dataframe
          The dataset in a dataframe to be written as a ts file
          which must be of the structure specified in the documentation
          examples/loading_data.ipynb.
          index |   dim_0   |   dim_1   |    ...    |  dim_c-1
             0  | pd.Series | pd.Series | pd.Series | pd.Series
             1  | pd.Series | pd.Series | pd.Series | pd.Series
            ... |    ...    |    ...    |    ...    |    ...
             n  | pd.Series | pd.Series | pd.Series | pd.Series
      path: str
          The full path to output the ts file to.
      problem_name: str, default="sample_data"
          The problemName to print in the header of the ts file and also the name of
          the file.
      class_label: list of str or None, default=None
          The problems class labels to show the possible class values for in the file
          header, optional.
      class_value_list: list, ndarray or None, default=None
          The class values for each case, optional.
      equal_length: bool, default=False
          Indicates whether each series is of equal length.
      series_length: int, default=-1
          Indicates the series length if they are of equal length.
      missing_values: str, default="NaN"
          Representation for missing values.
      comment: str or None, default=None
          Comment text to be inserted before the header in a block.
      fold: str or None, default=None
          Addon at the end of the filename, i.e. _TRAIN or _TEST.
  
      Returns
      -------
      None
  
      Notes
      -----
      This version currently does not support writing timestamp data.
      """
      # ensure data provided is a dataframe
      if not isinstance(data, pd.DataFrame):
          raise ValueError(
              f"Data provided must be a DataFrame, passed a {type(data)}"
          )
      data_valid, _, metadata = check_is_scitype(
          data, scitype="Panel", return_metadata=True
      )
      if not data_valid:
          raise ValueError("DataFrame provided is not a valid type")
      if equal_length != metadata["is_equal_length"]:
          raise ValueError(
              f"Argument passed for equal length = {equal_length} is not "
              f"true for the data passed"
          )
      if equal_length:
          # Convert to [cases][dimensions][length] numpy.
          data = convert_to(
              data,
              to_type="numpy3D",
              as_scitype="Panel",
              store_behaviour="freeze",
          )
          write_ndarray_to_tsfile(
              data,
              path,
              problem_name=problem_name,
              class_label=class_label,
              class_value_list=class_value_list,
              equal_length=equal_length,
              series_length=data.shape[2],
              missing_values=missing_values,
              comment=comment,
              fold=fold,
          )
      else:  # Write by iterating over dataframe
          if class_value_list is not None and class_label is None:
              class_label = np.unique(class_value_list)
          file = _write_header(
              path,
              problem_name,
              metadata["is_univariate"],
              metadata["is_equal_length"],
              series_length,
              class_label,
              fold,
              comment,
          )
          n_cases, n_dimensions = data.shape
          for i in range(0, n_cases):
              for j in range(0, n_dimensions):
                  series = data.iloc[i, j]
                  for k in range(0, series.size - 1):
                      file.write(f"{series[k]},")
                  file.write(f"{series[series.size-1]}:")
              file.write(f"{class_value_list[i]}\n")
  
file_path: sktime/sktime/datasets/_readers_writers/ts.py
imports: import itertools
  import numpy
  import pandas
  from sktime.datasets._readers_writers.utils import _alias_mtype_check, _write_header
  from sktime.datatypes import MTYPE_LIST_PANEL, check_is_scitype, convert, convert_to
  from sktime.utils.validation.panel import check_X, check_X_y
label_desc: Use image node_id 3 for calling a global function with example usage: write_dataframe_to_tsfile(data, path, problem_name, class_label, class_value_list, equal_length, series_length, missing_values, comment, fold) without return types