code: def from_long_to_nested(
      X_long,
      instance_column_name="case_id",
      time_column_name="reading_id",
      dimension_column_name="dim_id",
      value_column_name="value",
      column_names=None,
  ):
      """Convert long DataFrame to a nested DataFrame.
  
      Parameters
      ----------
      X_long : pd.DataFrame
          The long DataFrame
  
      instance_column_name : str, default = 'case_id'
          The name of column corresponding to the DataFrame's instances.
  
      time_column_name : str, default = 'reading_id'
          The name of the column corresponding to the DataFrame's timepoints.
  
      dimension_column_name : str, default = 'dim_id'
          The name of the column corresponding to the DataFrame's dimensions.
  
      value_column_name : str, default = 'value'
          The name of the column corresponding to the DataFrame's values.
  
      column_names : list, optional
          Optional list of column names to use for nested DataFrame columns.
  
      Returns
      -------
      X_nested : pd.DataFrame
          Nested pandas DataFrame
      """
      X_nested = X_long.pivot(
          index=[instance_column_name, time_column_name],
          columns=dimension_column_name,
          values=value_column_name,
      )
      X_nested = from_multi_index_to_nested(
          X_nested, instance_index=instance_column_name
      )
  
      n_columns = X_nested.shape[1]
      if column_names is None:
          X_nested.columns = _make_column_names(n_columns)
  
      else:
          X_nested.columns = column_names
  
      return X_nested
  
imports: import numpy
  import pandas
  from sktime.datatypes._convert_utils._coerce import _coerce_df_dtypes
  from sktime.datatypes._convert_utils._convert import _extend_conversions
  from sktime.datatypes._panel._registry import MTYPE_LIST_PANEL
  from sktime.utils.pandas import df_map
  from sktime.utils.validation._dependencies import _check_soft_dependencies
label_desc: Use image node_id 23 for calling a global function with example usage: from_long_to_nested(X_long, instance_column_name, time_column_name, dimension_column_name, value_column_name, column_names) and returns: X_nested