code: def concat(series, axis=0, allow_mix=False):
      """
      Concatenate a set of series.
  
      Parameters
      ----------
      series : iterable
          An iterable of series to be concatenated
      axis : int, optional
          The axis along which to concatenate. Default is 1 (columns).
      allow_mix : bool
          Whether or not to allow a mix of pandas and non-pandas objects. Default
          is False. If true, the returned object is an ndarray, and additional
          pandas metadata (e.g. column names, indices, etc) is lost.
  
      Returns
      -------
      concatenated : array or pd.DataFrame
          The concatenated array. Will be a DataFrame if series are pandas
          objects.
      """
      is_pandas = np.r_[[_is_using_pandas(s, None) for s in series]]
      ndim = np.r_[[np.ndim(s) for s in series]]
      max_ndim = np.max(ndim)
  
      if max_ndim > 2:
          raise ValueError(
              "`tools.concat` does not support arrays with 3 or"
              " more dimensions."
          )
  
      # Make sure the iterable is mutable
      if isinstance(series, tuple):
          series = list(series)
  
      # Standardize ndim
      for i in range(len(series)):
          if ndim[i] == 0 and max_ndim == 1:
              series[i] = np.atleast_1d(series[i])
          elif ndim[i] == 0 and max_ndim == 2:
              series[i] = np.atleast_2d(series[i])
          elif ndim[i] == 1 and max_ndim == 2 and is_pandas[i]:
              name = series[i].name
              series[i] = series[i].to_frame()
              series[i].columns = [name]
          elif ndim[i] == 1 and max_ndim == 2 and not is_pandas[i]:
              series[i] = np.atleast_2d(series[i]).T
  
      if np.all(is_pandas):
          if isinstance(series[0], pd.DataFrame):
              base_columns = series[0].columns
          else:
              base_columns = pd.Index([series[0].name])
          for i in range(1, len(series)):
              s = series[i]
  
              if isinstance(s, pd.DataFrame):
                  # Handle case where we were passed a dataframe and a series
                  # to concatenate, and the series did not have a name.
                  if s.columns.equals(pd.Index([None])):
                      s.columns = base_columns[:1]
                  s_columns = s.columns
              else:
                  s_columns = pd.Index([s.name])
  
              if axis == 0 and not base_columns.equals(s_columns):
                  raise ValueError(
                      "Columns must match to concatenate along" " rows."
                  )
              elif axis == 1 and not series[0].index.equals(s.index):
                  raise ValueError(
                      "Index must match to concatenate along"
                      " columns."
                  )
          concatenated = pd.concat(series, axis=axis)
      elif np.all(~is_pandas) or allow_mix:
          concatenated = np.concatenate(series, axis=axis)
      else:
          raise ValueError(
              "Attempted to concatenate Pandas objects with"
              " non-Pandas objects with `allow_mix=False`."
          )
  
      return concatenated
  
imports: import numpy
  from scipy.linalg import solve_sylvester
  import pandas
  from statsmodels.compat.pandas import Appender
  from statsmodels.tools.data import _is_using_pandas
  from scipy.linalg.blas import find_best_blas_type
  from .None import _initialization, _representation, _kalman_filter, _kalman_smoother, _simulation_smoother, _cfa_simulation_smoother, _tools
label_desc: Use image node_id 4 for calling a global function with example usage: concat(series, axis, allow_mix) and returns: concatenated