code: def to_scalar_df(df: pd.DataFrame) -> pd.DataFrame:
      """Converts all columns in a pd.DataFrame to be scalar types.
  
      For object columns of lists, each element of the list is expanded into its own column named {column}_{index}. We
      assume all object columns are lists of the same length (i.e., tensor format output from preprocessing). It's also
      important that the relative order of the columns is preserved, to maintain consistency with other conversions like
      the one for Hummingbird.
      """
      scalar_df = df
      column_ordering = []
      for c, s in df.items():
          if s.dtype == "object":
              s_list = s.to_list()
              try:
                  ncols = s_list[0].shape[0]
                  split_cols = [f"{c}_{k}" for k in range(ncols)]
                  sdf = pd.DataFrame(s_list, columns=split_cols)
                  scalar_df = pd.concat([scalar_df, sdf], axis=1)
                  column_ordering += split_cols
              except AttributeError as e:
                  raise ValueError(
                      f"Expected series of lists, but found {s_list[0]}"
                  ) from e
          else:
              column_ordering.append(c)
      return scalar_df[column_ordering]
  
file_path: ludwig/ludwig/utils/dataframe_utils.py
imports: from typing import Dict, List, Optional, Tuple
  import numpy
  import pandas
  from ludwig.api_annotations import DeveloperAPI
  from ludwig.constants import DASK_MODULE_NAME
  from ludwig.data.dataframe.base import DataFrameEngine
  from ludwig.utils.types import DataFrame
label_desc: Use image node_id 11 for calling a global function with example usage: to_scalar_df(df) and returns: scalar_df