# Buggy code
def __call__(self, df):
    # Note [Fancy Index of Numpy and Pandas]
    #
    # The numpy and pandas.iloc have different semantic when processing fancy index:
    #
    # >>> np.ones((3,3))[[1,2],[1,2]]
    # array([1., 1.])
    #
    # >>> pd.DataFrame(np.ones((3,3))).iloc[[1,2],[1,2]]
    #    1    2
    # 1  1.0  1.0
    # 2  1.0  1.0
    #
    # Thus, we processing the index along two axis of DataFrame seperately.

    if isinstance(self.indexes[0], TENSOR_TYPE) or isinstance(
        self.indexes[1], TENSOR_TYPE
    ):
        raise NotImplementedError("The index value cannot be unexecuted mars tensor")

    shape0 = tuple(calc_shape((df.shape[0],), (self.indexes[0],)))
    shape1 = tuple(calc_shape((df.shape[1],), (self.indexes[1],)))

    # NB: pandas only compresses the result to series when index on one of axis is integral
    if isinstance(self.indexes[1], Integral):
        shape = shape0
        dtype = df.dtypes.iloc[self.indexes[1]]
        index_value = indexing_index_value(df.index_value, self.indexes[0])
        self._object_type = ObjectType.series
        return self.new_series([df], shape=shape, dtype=dtype, index_value=index_value)
    elif isinstance(self.indexes[0], Integral):
        shape = shape1
        dtype = find_common_type(df.dtypes.iloc[self.indexes[1]].values)
        index_value = indexing_index_value(df.columns, self.indexes[1])
        self._object_type = ObjectType.series
        return self.new_series([df], shape=shape, dtype=dtype, index_value=index_value)
    else:
        return self.new_dataframe(
            [df],
            shape=shape0 + shape1,
            dtypes=df.dtypes.iloc[self.indexes[1]],
            index_value=indexing_index_value(df.index_value, self.indexes[0]),
            columns_value=indexing_index_value(
                df.columns, self.indexes[1], store_data=True
            ),
        )


# Traceback (Exception)
In [28]: df = md.DataFrame(np.random.rand(10, 2))

In [29]: df + np.random.rand(10, 2)
---------------------------------------------------------------------------
Exception                                 Traceback (most recent call last)
<ipython-input-29-4a212df011a8> in <module>
----> 1 df + np.random.rand(10, 2)

~/Documents/mars_dev/mars/mars/dataframe/utils.py in wrapper(*args, **kwargs)
613     def wrapper(*args, **kwargs):
614         try:
--> 615             return func(*args, **kwargs)
616         except NotImplementedError:
617             return NotImplemented

~/Documents/mars_dev/mars/mars/dataframe/arithmetic/add.py in add(df, other, axis, level, fill_value)
33
34 def add(df, other, axis='columns', level=None, fill_value=None):
---> 35     other = wrap_sequence(other)
36     op = DataFrameAdd(axis=axis, level=level, fill_value=fill_value, lhs=df, rhs=other)
37     return op(df, other)

~/Documents/mars_dev/mars/mars/dataframe/utils.py in wrap_sequence(seq)
606
607     if isinstance(seq, (list, tuple, np.ndarray, TENSOR_TYPE)):
--> 608         seq = Series(seq)
609     return seq
610

~/Documents/mars_dev/mars/mars/dataframe/initializer.py in __init__(self, data, index, dtype, name, copy, chunk_size, gpu, sparse)
46             series = data
47         else:
---> 48             pd_series = pd.Series(data, index=index, dtype=dtype, name=name, copy=copy)
49             series = from_pandas_series(pd_series, chunk_size=chunk_size, gpu=gpu, sparse=sparse)
50         super(Series, self).__init__(series.data)

~/miniconda3/lib/python3.7/site-packages/pandas/core/series.py in __init__(self, data, index, dtype, name, copy, fastpath)
312                     data = data.copy()
313             else:
--> 314                 data = sanitize_array(data, index, dtype, copy, raise_cast_failure=True)
315
316                 data = SingleBlockManager(data, index, fastpath=True)

~/miniconda3/lib/python3.7/site-packages/pandas/core/internals/construction.py in sanitize_array(data, index, dtype, copy, raise_cast_failure)
727     elif subarr.ndim > 1:
728         if isinstance(data, np.ndarray):
--> 729             raise Exception("Data must be 1-dimensional")
730         else:
731             subarr = com.asarray_tuplesafe(data, dtype=dtype)

Exception: Data must be 1-dimensional

# Fixed code
def __call__(self, df):
    # Note [Fancy Index of Numpy and Pandas]
    #
    # The numpy and pandas.iloc have different semantic when processing fancy index:
    #
    # >>> np.ones((3,3))[[1,2],[1,2]]
    # array([1., 1.])
    #
    # >>> pd.DataFrame(np.ones((3,3))).iloc[[1,2],[1,2]]
    #    1    2
    # 1  1.0  1.0
    # 2  1.0  1.0
    #
    # Thus, we processing the index along two axis of DataFrame seperately.

    if isinstance(self.indexes[0], TENSOR_TYPE) or isinstance(
        self.indexes[1], TENSOR_TYPE
    ):
        raise NotImplementedError("The index value cannot be unexecuted mars tensor")

    shape0 = tuple(calc_shape((df.shape[0],), (self.indexes[0],)))
    shape1 = tuple(calc_shape((df.shape[1],), (self.indexes[1],)))

    # NB: pandas only compresses the result to series when index on one of axis is integral
    if isinstance(self.indexes[1], Integral):
        shape = shape0
        dtype = df.dtypes.iloc[self.indexes[1]]
        index_value = indexing_index_value(df.index_value, self.indexes[0])
        self._object_type = ObjectType.series
        return self.new_series([df], shape=shape, dtype=dtype, index_value=index_value)
    elif isinstance(self.indexes[0], Integral):
        shape = shape1
        dtype = find_common_type(df.dtypes.iloc[self.indexes[1]].values)
        index_value = indexing_index_value(df.columns_value, self.indexes[1])
        self._object_type = ObjectType.series
        return self.new_series([df], shape=shape, dtype=dtype, index_value=index_value)
    else:
        return self.new_dataframe(
            [df],
            shape=shape0 + shape1,
            dtypes=df.dtypes.iloc[self.indexes[1]],
            index_value=indexing_index_value(df.index_value, self.indexes[0]),
            columns_value=indexing_index_value(
                df.columns_value, self.indexes[1], store_data=True
            ),
        )