parameters: (self, indexer, ser, multiindex_indexer=False)
docstring: Parameters
          ----------
          indexer : tuple, slice, scalar
              The indexer used to get the locations that will be set to
              `ser`
  
          ser : pd.Series
              The values to assign to the locations specified by `indexer`
  
          multiindex_indexer : boolean, optional
              Defaults to False. Should be set to True if `indexer` was from
              a `pd.MultiIndex`, to avoid unnecessary broadcasting.
  
  
          Returns:
          --------
          `np.array` of `ser` broadcast to the appropriate shape for assignment
          to the locations selected by `indexer`
docstring_summary: Parameters
          ----------
          indexer : tuple, slice, scalar
              The indexer used to get the locations that will be set to
              `ser`
docstring_tokens: Parameters ---------- indexer : tuple slice scalar The indexer used to get the locations that will be set to ser
function: def _align_series(self, indexer, ser, multiindex_indexer=False):
          """
          Parameters
          ----------
          indexer : tuple, slice, scalar
              The indexer used to get the locations that will be set to
              `ser`
  
          ser : pd.Series
              The values to assign to the locations specified by `indexer`
  
          multiindex_indexer : boolean, optional
              Defaults to False. Should be set to True if `indexer` was from
              a `pd.MultiIndex`, to avoid unnecessary broadcasting.
  
  
          Returns:
          --------
          `np.array` of `ser` broadcast to the appropriate shape for assignment
          to the locations selected by `indexer`
  
          """
          if isinstance(indexer, (slice, np.ndarray, list, Index)):
              indexer = tuple([indexer])
  
          if isinstance(indexer, tuple):
  
              # flatten np.ndarray indexers
              def ravel(i):
                  return i.ravel() if isinstance(i, np.ndarray) else i
              indexer = tuple(map(ravel, indexer))
  
              aligners = [not com.is_null_slice(idx) for idx in indexer]
              sum_aligners = sum(aligners)
              single_aligner = sum_aligners == 1
              is_frame = self.obj.ndim == 2
              is_panel = self.obj.ndim >= 3
              obj = self.obj
  
              # are we a single alignable value on a non-primary
              # dim (e.g. panel: 1,2, or frame: 0) ?
              # hence need to align to a single axis dimension
              # rather that find all valid dims
  
              # frame
              if is_frame:
                  single_aligner = single_aligner and aligners[0]
  
              # panel
              elif is_panel:
                  single_aligner = (single_aligner and
                                    (aligners[1] or aligners[2]))
  
              # we have a frame, with multiple indexers on both axes; and a
              # series, so need to broadcast (see GH5206)
              if (sum_aligners == self.ndim and
                      all(is_sequence(_) for _ in indexer)):
                  ser = ser.reindex(obj.axes[0][indexer[0]], copy=True)._values
  
                  # single indexer
                  if len(indexer) > 1 and not multiindex_indexer:
                      len_indexer = len(indexer[1])
                      ser = np.tile(ser, len_indexer).reshape(len_indexer, -1).T
  
                  return ser
  
              for i, idx in enumerate(indexer):
                  ax = obj.axes[i]
  
                  # multiple aligners (or null slices)
                  if is_sequence(idx) or isinstance(idx, slice):
                      if single_aligner and com.is_null_slice(idx):
                          continue
                      new_ix = ax[idx]
                      if not is_list_like_indexer(new_ix):
                          new_ix = Index([new_ix])
                      else:
                          new_ix = Index(new_ix)
                      if ser.index.equals(new_ix) or not len(new_ix):
                          return ser._values.copy()
  
                      return ser.reindex(new_ix)._values
  
                  # 2 dims
                  elif single_aligner and is_frame:
  
                      # reindex along index
                      ax = self.obj.axes[1]
                      if ser.index.equals(ax) or not len(ax):
                          return ser._values.copy()
                      return ser.reindex(ax)._values
  
                  # >2 dims
                  elif single_aligner:
  
                      broadcast = []
                      for n, labels in enumerate(self.obj._get_plane_axes(i)):
  
                          # reindex along the matching dimensions
                          if len(labels & ser.index):
                              ser = ser.reindex(labels)
                          else:
                              broadcast.append((n, len(labels)))
  
                      # broadcast along other dims
                      ser = ser._values.copy()
                      for (axis, l) in broadcast:
                          shape = [-1] * (len(broadcast) + 1)
                          shape[axis] = l
                          ser = np.tile(ser, l).reshape(shape)
  
                      if self.obj.ndim == 3:
                          ser = ser.T
  
                      return ser
  
          elif is_scalar(indexer):
              ax = self.obj._get_axis(1)
  
              if ser.index.equals(ax):
                  return ser._values.copy()
  
              return ser.reindex(ax)._values
  
          raise ValueError('Incompatible indexer with Series')
function_tokens: def _align_series ( self , indexer , ser , multiindex_indexer = False ) : if isinstance ( indexer , ( slice , np . ndarray , list , Index ) ) : indexer = tuple ( [ indexer ] ) if isinstance ( indexer , tuple ) : # flatten np.ndarray indexers def ravel ( i ) : return i . ravel ( ) if isinstance ( i , np . ndarray ) else i indexer = tuple ( map ( ravel , indexer ) ) aligners = [ not com . is_null_slice ( idx ) for idx in indexer ] sum_aligners = sum ( aligners ) single_aligner = sum_aligners == 1 is_frame = self . obj . ndim == 2 is_panel = self . obj . ndim >= 3 obj = self . obj # are we a single alignable value on a non-primary # dim (e.g. panel: 1,2, or frame: 0) ? # hence need to align to a single axis dimension # rather that find all valid dims # frame if is_frame : single_aligner = single_aligner and aligners [ 0 ] # panel elif is_panel : single_aligner = ( single_aligner and ( aligners [ 1 ] or aligners [ 2 ] ) ) # we have a frame, with multiple indexers on both axes; and a # series, so need to broadcast (see GH5206) if ( sum_aligners == self . ndim and all ( is_sequence ( _ ) for _ in indexer ) ) : ser = ser . reindex ( obj . axes [ 0 ] [ indexer [ 0 ] ] , copy = True ) . _values # single indexer if len ( indexer ) > 1 and not multiindex_indexer : len_indexer = len ( indexer [ 1 ] ) ser = np . tile ( ser , len_indexer ) . reshape ( len_indexer , - 1 ) . T return ser for i , idx in enumerate ( indexer ) : ax = obj . axes [ i ] # multiple aligners (or null slices) if is_sequence ( idx ) or isinstance ( idx , slice ) : if single_aligner and com . is_null_slice ( idx ) : continue new_ix = ax [ idx ] if not is_list_like_indexer ( new_ix ) : new_ix = Index ( [ new_ix ] ) else : new_ix = Index ( new_ix ) if ser . index . equals ( new_ix ) or not len ( new_ix ) : return ser . _values . copy ( ) return ser . reindex ( new_ix ) . _values # 2 dims elif single_aligner and is_frame : # reindex along index ax = self . obj . axes [ 1 ] if ser . index . equals ( ax ) or not len ( ax ) : return ser . _values . copy ( ) return ser . reindex ( ax ) . _values # >2 dims elif single_aligner : broadcast = [ ] for n , labels in enumerate ( self . obj . _get_plane_axes ( i ) ) : # reindex along the matching dimensions if len ( labels & ser . index ) : ser = ser . reindex ( labels ) else : broadcast . append ( ( n , len ( labels ) ) ) # broadcast along other dims ser = ser . _values . copy ( ) for ( axis , l ) in broadcast : shape = [ - 1 ] * ( len ( broadcast ) + 1 ) shape [ axis ] = l ser = np . tile ( ser , l ) . reshape ( shape ) if self . obj . ndim == 3 : ser = ser . T return ser elif is_scalar ( indexer ) : ax = self . obj . _get_axis ( 1 ) if ser . index . equals ( ax ) : return ser . _values . copy ( ) return ser . reindex ( ax ) . _values raise ValueError ( 'Incompatible indexer with Series' )