class_docstr: Wrap array_like using the index from the original input, if pandas
  
  Parameters
  ----------
  pandas_obj : {Series, DataFrame}
      Object to extract the index from for wrapping
  
  Notes
  -----
  Raises if ``orig`` is a pandas type but obj and and ``orig`` have
  different numbers of elements in axis 0. Also raises if the ndim of obj
  is larger than 2.
class_docstr_tok: ["Wrap","array_like","using","the","index","from","the","original","input",",","if","pandas","Parameters","--","--","--","--","--","pandas_obj",":","{","Series",",","DataFrame","}","Object","to","extract","the","index","from","for","wrapping","Notes","--","--","-","Raises","if","``","orig","``","is","a","pandas","type","but","obj","and","and","``","orig","``","have","different","numbers","of","elements","in","axis","0",".","Also","raises","if","the","ndim","of","obj","is","larger","than","2","."]
docstr: Parameters
  ----------
  obj : {array_like}
      The value to wrap like to a pandas Series or DataFrame.
  columns : {str, list[str]}
      Column names or series name, if obj is 1d.
  append : str
      String to append to the columns to create a new column name.
  trim_start : int
      The number of observations to drop from the start of the index, so
      that the index applied is index[trim_start:].
  trim_end : int
      The number of observations to drop from the end of the index , so
      that the index applied is index[:nobs - trim_end].
  
  Returns
  -------
  array_like
      A pandas Series or DataFrame, depending on the shape of obj.
docstr_tok: ["Parameters","--","--","--","--","--","obj",":","{","array_like","}","The","value","to","wrap","like","to","a","pandas","Series","or","DataFrame",".","columns",":","{","str",",","list","[","str","]","}","Column","names","or","series","name",",","if","obj","is","1d",".","append",":","str","String","to","append","to","the","columns","to","create","a","new","column","name",".","trim_start",":","int","The","number","of","observations","to","drop","from","the","start","of","the","index",",","so","that","the","index","applied","is","index","[","trim_start",":","]",".","trim_end",":","int","The","number","of","observations","to","drop","from","the","end","of","the","index",",","so","that","the","index","applied","is","index","[",":","nobs","-","trim_end","]",".","Returns","--","--","--","-","array_like","A","pandas","Series","or","DataFrame",",","depending","on","the","shape","of","obj","."]
code: def wrap(
      self, obj, columns=None, append=None, trim_start=0, trim_end=0
  ):
      """
      Parameters
      ----------
      obj : {array_like}
          The value to wrap like to a pandas Series or DataFrame.
      columns : {str, list[str]}
          Column names or series name, if obj is 1d.
      append : str
          String to append to the columns to create a new column name.
      trim_start : int
          The number of observations to drop from the start of the index, so
          that the index applied is index[trim_start:].
      trim_end : int
          The number of observations to drop from the end of the index , so
          that the index applied is index[:nobs - trim_end].
  
      Returns
      -------
      array_like
          A pandas Series or DataFrame, depending on the shape of obj.
      """
      obj = np.asarray(obj)
      if not self._is_pandas:
          return obj
  
      if (
          obj.shape[0] + trim_start + trim_end
          != self._pandas_obj.shape[0]
      ):
          raise ValueError(
              "obj must have the same number of elements in "
              "axis 0 as orig"
          )
      index = self._pandas_obj.index
      index = index[trim_start : index.shape[0] - trim_end]
      if obj.ndim == 1:
          if columns is None:
              name = getattr(self._pandas_obj, "name", None)
          elif isinstance(columns, str):
              name = columns
          else:
              name = columns[0]
          if append is not None:
              name = append if name is None else f"{name}_{append}"
  
          return pd.Series(obj, name=name, index=index)
      elif obj.ndim == 2:
          if columns is None:
              columns = getattr(self._pandas_obj, "columns", None)
          if append is not None:
              new = []
              for c in columns:
                  new.append(append if c is None else f"{c}_{append}")
              columns = new
          return pd.DataFrame(obj, columns=columns, index=index)
      else:
          raise ValueError("Can only wrap 1 or 2-d array_like")
  
file_path: statsmodels/statsmodels/tools/validation/validation.py
imports: from typing import Any, Optional
  from collections.abc import Mapping
  import numpy
  import pandas
label_desc: Use image node_id 2 for calling the PandasWrapper obj's underlying member method code with example usage: obj.wrap(obj, columns, append, trim_start, trim_end) and returns: obj, pd, pd