code: def to_tsfresh_dataset(X):
      """Transform a tslearn-compatible dataset into a tsfresh dataset.
  
      Parameters
      ----------
      X: array, shape = (n_ts, sz, d)
          tslearn-formatted dataset to be cast to tsfresh format
  
      Returns
      -------
      Pandas data-frame
          tsfresh-formatted dataset ("flat" data frame, as described
          `there <https://tsfresh.readthedocs.io/en/latest/text/data_formats.html#input-option-1-flat-dataframe>`_)
  
      Examples
      --------
      >>> tslearn_arr = numpy.random.randn(1, 16, 1)
      >>> tsfresh_df = to_tsfresh_dataset(tslearn_arr)
      >>> tsfresh_df.shape
      (16, 3)
      >>> tslearn_arr = numpy.random.randn(1, 16, 2)
      >>> tsfresh_df = to_tsfresh_dataset(tslearn_arr)
      >>> tsfresh_df.shape
      (16, 4)
  
      Notes
      -----
      Conversion from/to tsfresh format requires pandas to be installed.
      """  # noqa: E501
      try:
          import pandas as pd
      except ImportError:
          raise ImportError(
              "Conversion from/to tsfresh cannot be performed "
              "if pandas is not installed."
          )
      X_ = check_dataset(X)
      n, sz, d = X_.shape
      dataframes = []
      for i, Xi in enumerate(X_):
          df = pd.DataFrame(
              columns=["id", "time"]
              + ["dim_%d" % di for di in range(d)]
          )
          Xi_ = Xi[: ts_size(Xi)]
          sz = Xi_.shape[0]
          df["time"] = numpy.arange(sz)
          df["id"] = numpy.zeros((sz,), dtype=int) + i
          for di in range(d):
              df["dim_%d" % di] = Xi_[:, di]
          dataframes.append(df)
      return pd.concat(dataframes)
  
file_path: tslearn/tslearn/utils/cast.py
imports: import warnings
  import numpy
  from sklearn.utils import check_array
  from .utils import check_dataset, ts_size, to_time_series_dataset
label_desc: Use image node_id 12 for calling a global function with example usage: to_tsfresh_dataset(X) and returns: pd