docstr: Returns an object of the type of the column owner or updates the column
  of the owner (Series or Index) to mimic an inplace operation
docstr_tok: ["Returns","an","object","of","the","type","of","the","column","owner","or","updates","the","column","of","the","owner","(","Series","or","Index",")","to","mimic","an","inplace","operation"]
code: def _return_or_inplace(
      self, new_col, inplace=False, expand=False, retain_index=True
  ):
      """
      Returns an object of the type of the column owner or updates the column
      of the owner (Series or Index) to mimic an inplace operation
      """
      if inplace:
          self._parent._mimic_inplace(
              self._parent.__class__._from_data(
                  {self._parent.name: new_col}
              ),
              inplace=True,
          )
          return None
      else:
          if expand:
              # This branch indicates the passed as new_col
              # is a Table
              table = new_col
  
              if isinstance(self._parent, cudf.BaseIndex):
                  idx = self._parent._constructor_expanddim._from_data(
                      table
                  )
                  idx.names = None
                  return idx
              else:
                  return self._parent._constructor_expanddim._from_data(
                      data=table, index=self._parent.index
                  )
          elif isinstance(self._parent, cudf.Series):
              if retain_index:
                  return cudf.Series(
                      new_col,
                      name=self._parent.name,
                      index=self._parent.index,
                  )
              else:
                  return cudf.Series(new_col, name=self._parent.name)
          elif isinstance(self._parent, cudf.BaseIndex):
              return cudf.core.index.as_index(
                  new_col, name=self._parent.name
              )
          else:
              return self._parent._mimic_inplace(new_col, inplace=False)
  
file_path: cudf/python/cudf/cudf/core/column/methods.py
imports: from __future__ import annotations
  from typing import Optional, Union, overload
  from typing_extensions import Literal
  import cudf
  from cudf.utils.utils import NotIterable
label_desc: Use image node_id 6 for calling the ColumnMethods obj's underlying member method code with example usage: obj._return_or_inplace(new_col, inplace, expand, retain_index) and returns: None, idx, self, cudf, cudf, cudf, self