code: def seasonal_split(data: pd.Series) -> pd.DataFrame:
      """
      Splits the data by season:
          * Quarterly - Years by Quarters
          * Monthly - Years by Months
          * Weekly - Years by Weeks
          * Daily - Year+Months by Days
          * Business daily - Week by Day of the Week
          * Hourly - Year+Month+Day by Hours
  
      Args:
          data (pd.Series): Time series split.
  
      Returns:
          pd.DataFrame: Seasonally split data.
  
      """
      freq_by = {
          "Q": ("%Y", "%m"),
          "M": ("%Y", "%m"),
          "W": ("%G", "W%V"),
          "D": ("%Y-%m", "%d"),
          "B": ("%G-%V", "%w-%a"),
          "H": ("%Y-%m-%d", "%H"),
      }
      freq = data.index.inferred_freq
      freq = freq[0] if freq else ""
      if freq in freq_by:
          fmt_season, fmt_freq = freq_by[freq]
  
          return (
              pd.DataFrame(
                  {
                      "season": data.index.strftime(fmt_season),
                      "freq": data.index.strftime(fmt_freq),
                      "value": data.values,
                  }
              )
              .set_index(["season", "freq"])
              .unstack(0)
              .droplevel(0, axis=1)
          )
      return pd.DataFrame()
  
imports: from typing import Optional
  import pandas
  from statsmodels.tsa.seasonal import STL
  from statsmodels.tsa.tsatools import freq_to_period
  from tslumen.profile.base import ProfilingFunction
label_desc: Use image node_id 2 for calling a global function with example usage: seasonal_split(data) and returns: pd, pd