code: def slice_axis_attributes(old, oldaxis, new, newaxis, slice_):
      
      slice_ = as_slice(slice_)
  
      # attribute names
      index = '{}index'.format
      origin = '{}0'.format
      delta = 'd{}'.format
  
      # if array has an index set already, use it
      if hasattr(old, '_{}index'.format(oldaxis)):
          setattr(new, index(newaxis), getattr(old, index(oldaxis))[slice_])
  
      # otherwise if using a slice, use origin and delta properties
      elif isinstance(slice_, slice) or not numpy.sum(slice_):
          if isinstance(slice_, slice):
              offset = slice_.start or 0
              step = slice_.step or 1
          else:  # empty ndarray slice (so just set attributes)
              offset = 0
              step = 1
  
          dx = getattr(old, delta(oldaxis))
          x0 = getattr(old, origin(oldaxis))
  
          # set new.x0 / new.y0
          setattr(new, origin(newaxis), x0 + offset * dx)
  
          # set new.dx / new.dy
          setattr(new, delta(newaxis), dx * step)
  
      # otherwise slice with an index array
      else:
          setattr(new, index(newaxis), getattr(old, index(oldaxis))[slice_])
  
      return new
docs: Set axis metadata for ``new`` by slicing an axis of ``old``
  
      This is primarily for internal use in slice functions (__getitem__)
  
      Parameters
      ----------
      old : `Array`
          array being sliced
  
      oldaxis : ``'x'`` or ``'y'``
          the axis to slice
  
      new : `Array`
          product of slice
  
      newaxis : ``'x'`` or ``'y'``
          the target axis
  
      slice_ : `slice`, `numpy.ndarray`
          the slice to apply to old (or an index array)
  
      See Also
      --------
      Series.__getitem__
      Array2D.__getitem__