code: def from_tsfresh_dataset(X):
      """Transform a tsfresh-compatible dataset into a tslearn dataset.
  
      Parameters
      ----------
      X: 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>`_)
  
      Returns
      -------
      array, shape=(n_ts, sz, d)
          tslearn-formatted dataset.
          Column order is kept the same as in the original data frame.
  
      Examples
      --------
      >>> import pandas as pd
      >>> tsfresh_df = pd.DataFrame(columns=["id", "time", "a", "b"])
      >>> tsfresh_df["id"] = [0, 0, 0]
      >>> tsfresh_df["time"] = [0, 1, 2]
      >>> tsfresh_df["a"] = [-1, 4, 7]
      >>> tsfresh_df["b"] = [8, -3, 2]
      >>> tslearn_arr = from_tsfresh_dataset(tsfresh_df)
      >>> tslearn_arr.shape
      (1, 3, 2)
      >>> tsfresh_df = pd.DataFrame(columns=["id", "time", "a"])
      >>> tsfresh_df["id"] = [0, 0, 0, 1, 1]
      >>> tsfresh_df["time"] = [0, 1, 2, 0, 1]
      >>> tsfresh_df["a"] = [-1, 4, 7, 9, 1]
      >>> tslearn_arr = from_tsfresh_dataset(tsfresh_df)
      >>> tslearn_arr.shape
      (2, 3, 1)
      >>> tsfresh_df = numpy.random.randn(10, 1, 16)
      >>> from_tsfresh_dataset(
      ...     tsfresh_df
      ... )  # doctest: +IGNORE_EXCEPTION_DETAIL
      Traceback (most recent call last):
      ...
      ValueError: X is not a valid input tsfresh array.
  
      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."
          )
      if not isinstance(X, pd.DataFrame):
          raise ValueError(
              "X is not a valid input tsfresh array. "
              "A pandas DataFrame is expected."
          )
      data_dimensions = [
          col_name
          for col_name in X.columns
          if col_name not in ["id", "time"]
      ]
      d = len(data_dimensions)
      all_ids = set(X["id"])
      n = len(all_ids)
  
      max_sz = -1
      for ind_id in all_ids:
          sz = X[X["id"] == ind_id].shape[0]
          if sz > max_sz:
              max_sz = sz
  
      tslearn_arr = numpy.empty((n, max_sz, d))
      tslearn_arr[:] = numpy.nan
      for di, dim_name in enumerate(data_dimensions):
          for i, ind_id in enumerate(all_ids):
              data_ind = X[X["id"] == ind_id]
              data = data_ind[dim_name]
              sz = data_ind.shape[0]
              tslearn_arr[i, :sz, di] = data
      return tslearn_arr
  
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 13 for calling a global function with example usage: from_tsfresh_dataset(X) and returns: tslearn_arr