code: def pandas_to_series_spec(x):
      # from statsmodels.tools.data import _check_period_index
      # check_period_index(x)
      if hasattr(x, "columns"):  # convert to series
          if len(x.columns) > 1:
              raise ValueError(
                  "Does not handle DataFrame with more than one "
                  "column"
              )
          x = x[x.columns[0]]
  
      data = "({})".format("\n".join(map(str, x.values.tolist())))
  
      # get periodicity
      # get start / first data
      # give it a title
      try:
          period = _freq_to_period[x.index.freqstr]
      except (AttributeError, ValueError):
          from pandas.tseries.api import infer_freq
  
          period = _freq_to_period[infer_freq(x.index)]
      start_date = x.index[0]
      if period == 12:
          year, stperiod = start_date.year, start_date.month
      elif period == 4:
          year, stperiod = start_date.year, start_date.quarter
      else:  # pragma: no cover
          raise ValueError(
              "Only monthly and quarterly periods are supported."
              " Please report or send a pull request if you want "
              "this extended."
          )
  
      if hasattr(x, "name"):
          name = x.name or "Unnamed Series"
      else:
          name = "Unnamed Series"
      series_spec = SeriesSpec(
          data=data,
          name=name,
          period=period,
          title=name,
          start=f"{year}.{stperiod}",
      )
      return series_spec
  
imports: from statsmodels.compat.pandas import deprecate_kwarg
  import os
  import subprocess
  import tempfile
  import re
  from warnings import warn
  import pandas
  from statsmodels.tools.tools import Bunch
  from statsmodels.tools.sm_exceptions import X13NotFoundError, IOWarning, X13Error, X13Warning
label_desc: Use image node_id 12 for calling a global function with example usage: pandas_to_series_spec(x) and returns: series_spec