parameters: (left, right, axis)
return_statement: return right
docstring: convert rhs to meet lhs dims if input is list, tuple or np.ndarray
docstring_summary: convert rhs to meet lhs dims if input is list, tuple or np.ndarray
docstring_tokens: convert rhs to meet lhs dims if input is list tuple or np . ndarray
function: def _align_method_FRAME(left, right, axis):
      """ convert rhs to meet lhs dims if input is list, tuple or np.ndarray """
  
      def to_series(right):
          msg = "Unable to coerce to Series, length must be {req_len}: given {given_len}"
          if axis is not None and left._get_axis_name(axis) == "index":
              if len(left.index) != len(right):
                  raise ValueError(
                      msg.format(req_len=len(left.index), given_len=len(right))
                  )
              right = left._constructor_sliced(right, index=left.index)
          else:
              if len(left.columns) != len(right):
                  raise ValueError(
                      msg.format(req_len=len(left.columns), given_len=len(right))
                  )
              right = left._constructor_sliced(right, index=left.columns)
          return right
  
      if isinstance(right, np.ndarray):
  
          if right.ndim == 1:
              right = to_series(right)
  
          elif right.ndim == 2:
              if right.shape == left.shape:
                  right = left._constructor(right, index=left.index, columns=left.columns)
  
              elif right.shape[0] == left.shape[0] and right.shape[1] == 1:
                  # Broadcast across columns
                  right = np.broadcast_to(right, left.shape)
                  right = left._constructor(right, index=left.index, columns=left.columns)
  
              elif right.shape[1] == left.shape[1] and right.shape[0] == 1:
                  # Broadcast along rows
                  right = to_series(right[0, :])
  
              else:
                  raise ValueError(
                      "Unable to coerce to DataFrame, shape "
                      f"must be {left.shape}: given {right.shape}"
                  )
  
          elif right.ndim > 2:
              raise ValueError(
                  "Unable to coerce to Series/DataFrame, dim "
                  f"must be <= 2: {right.shape}"
              )
  
      elif is_list_like(right) and not isinstance(right, (ABCSeries, ABCDataFrame)):
          # GH17901
          right = to_series(right)
  
      return right
function_tokens: def _align_method_FRAME ( left , right , axis ) : def to_series ( right ) : msg = "Unable to coerce to Series, length must be {req_len}: given {given_len}" if axis is not None and left . _get_axis_name ( axis ) == "index" : if len ( left . index ) != len ( right ) : raise ValueError ( msg . format ( req_len = len ( left . index ) , given_len = len ( right ) ) ) right = left . _constructor_sliced ( right , index = left . index ) else : if len ( left . columns ) != len ( right ) : raise ValueError ( msg . format ( req_len = len ( left . columns ) , given_len = len ( right ) ) ) right = left . _constructor_sliced ( right , index = left . columns ) return right if isinstance ( right , np . ndarray ) : if right . ndim == 1 : right = to_series ( right ) elif right . ndim == 2 : if right . shape == left . shape : right = left . _constructor ( right , index = left . index , columns = left . columns ) elif right . shape [ 0 ] == left . shape [ 0 ] and right . shape [ 1 ] == 1 : # Broadcast across columns right = np . broadcast_to ( right , left . shape ) right = left . _constructor ( right , index = left . index , columns = left . columns ) elif right . shape [ 1 ] == left . shape [ 1 ] and right . shape [ 0 ] == 1 : # Broadcast along rows right = to_series ( right [ 0 , : ] ) else : raise ValueError ( "Unable to coerce to DataFrame, shape " f"must be {left.shape}: given {right.shape}" ) elif right . ndim > 2 : raise ValueError ( "Unable to coerce to Series/DataFrame, dim " f"must be <= 2: {right.shape}" ) elif is_list_like ( right ) and not isinstance ( right , ( ABCSeries , ABCDataFrame ) ) : # GH17901 right = to_series ( right ) return right