code: def flatten_spatial(df: pd.DataFrame, col) -> pd.DataFrame:
      # 4.x
      any_spatial4 = (df[col].apply(get_mod) == "neo4j.spatial").any()  # type: ignore
  
      # 5.x
      any_spatial5 = (df[col].apply(get_mod) == "neo4j._spatial").any()  # type: ignore
      if not any_spatial4 and not any_spatial5:
          return df
  
      with_vals: pd.Series = df[col].dropna()  # type: ignore
      if len(with_vals) == 0:  # type: ignore
          return df
  
      out_df: pd.DataFrame = df.copy(deep=False)  # type: ignore
  
      t0 = with_vals[0]  # type: ignore
      try:
          all_t0 = (with_vals.apply(lambda s: s.__class__) == t0.__class__).all()  # type: ignore
      except:
          all_t0 = False
  
      if all_t0:
          out_df = flatten_spatial_col(df, col)
      else:
          out_df[col] = df[col].apply(stringify_spatial)
  
      return out_df
  
file_path: pygraphistry/graphistry/bolt_util.py
imports: import pandas
  from datetime import datetime
  from .pygraphistry import util
  from .util import setup_logger
label_desc: Use image node_id 8 for calling a global function with example usage: flatten_spatial(df, col) and returns: out_df, df, df