code: def _wrap_output(self, output, index, names=None):
          
          output = output[self._selection_name]
  
          if names is not None:
              return DataFrame(output, index=index, columns=names)
          else:
              name = self._selection_name
              if name is None:
                  name = self._selected_obj.name
              return Series(output, index=index, name=name)
docs: common agg/transform wrapping logic