code: def from_sktime_dataset(X):
      """Transform a sktime-compatible dataset into a tslearn dataset.
  
      Parameters
      ----------
      X: pandas data-frame
          sktime-formatted dataset (cf.
          `link <https://alan-turing-institute.github.io/sktime/examples/loading_data.html>`_)
  
      Returns
      -------
      array, shape=(n_ts, sz, d)
          tslearn-formatted dataset
  
      Examples
      --------
      >>> import pandas as pd
      >>> sktime_df = pd.DataFrame()
      >>> sktime_df["dim_0"] = [pd.Series([1, 2, 3]), pd.Series([4, 5, 6])]
      >>> tslearn_arr = from_sktime_dataset(sktime_df)
      >>> tslearn_arr.shape
      (2, 3, 1)
      >>> sktime_df = pd.DataFrame()
      >>> sktime_df["dim_0"] = [pd.Series([1, 2, 3]),
      ...                       pd.Series([4, 5, 6, 7])]
      >>> sktime_df["dim_1"] = [pd.Series([8, 9, 10]),
      ...                       pd.Series([11, 12, 13, 14])]
      >>> tslearn_arr = from_sktime_dataset(sktime_df)
      >>> tslearn_arr.shape
      (2, 4, 2)
      >>> sktime_arr = numpy.random.randn(10, 1, 16)
      >>> from_sktime_dataset(
      ...     sktime_arr
      ... )  # doctest: +IGNORE_EXCEPTION_DETAIL
      Traceback (most recent call last):
      ...
      ValueError: X is not a valid input sktime array.
  
      Notes
      -----
      Conversion from/to sktime format requires pandas to be installed.
      """  # noqa: E501
      try:
          import pandas as pd
      except ImportError:
          raise ImportError(
              "Conversion from/to sktime cannot be performed "
              "if pandas is not installed."
          )
      if not isinstance(X, pd.DataFrame):
          raise ValueError(
              "X is not a valid input sktime array. "
              "A pandas DataFrame is expected."
          )
      data_dimensions = [
          col_name
          for col_name in X.columns
          if col_name.startswith("dim_")
      ]
      d = len(data_dimensions)
      ordered_data_dimensions = ["dim_%d" % di for di in range(d)]
      if sorted(ordered_data_dimensions) != sorted(data_dimensions):
          raise ValueError(
              "X is not a valid input sktime array. "
              "Provided dimensions are not conitiguous."
              "{}".format(data_dimensions)
          )
      n = X["dim_0"].shape[0]
      max_sz = -1
      for dim_name in ordered_data_dimensions:
          for i in range(n):
              if X[dim_name][i].size > max_sz:
                  max_sz = X[dim_name][i].size
  
      tslearn_arr = numpy.empty((n, max_sz, d))
      tslearn_arr[:] = numpy.nan
      for di in range(d):
          for i in range(n):
              sz = X["dim_%d" % di][i].size
              tslearn_arr[i, :sz, di] = X["dim_%d" % di][
                  i
              ].values.copy()
      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 9 for calling a global function with example usage: from_sktime_dataset(X) and returns: tslearn_arr