# Buggy code
def tile(cls, op):
    in_df = op.inputs[0]
    out_df = op.outputs[0]

    if not isinstance(op.keys, six.string_types):
        raise NotImplementedError("DataFrame.set_index only support label")
    if op.verify_integrity:
        raise NotImplementedError(
            "DataFrame.set_index not support verify_integrity yet"
        )

    out_chunks = []

    try:
        column_index = in_df.columns.to_pandas().get_loc(op.keys)
    except KeyError:
        raise NotImplementedError(
            "The new index label must be a column of the original dataframe"
        )

    chunk_index = np.searchsorted(np.cumsum(in_df.nsplits[1]), column_index + 1)

    for row_idx in range(in_df.chunk_shape[0]):
        index_chunk = in_df.cix[row_idx, chunk_index]
        for col_idx in range(in_df.chunk_shape[1]):
            input_chunk = in_df.cix[row_idx, col_idx]
            if op.drop and input_chunk.key == index_chunk.key:
                new_shape = (input_chunk.shape[0], input_chunk.shape[1] - 1)
                columns = parse_index(
                    input_chunk.columns.to_pandas().drop(op.keys), store_data=True
                )
            else:
                new_shape = input_chunk.shape
                columns = input_chunk.columns
            out_op = op.copy().reset_key()
            out_chunk = out_op.new_chunk(
                [index_chunk, input_chunk],
                shape=new_shape,
                dtypes=out_df.dtypes,
                index=input_chunk.index,
                index_value=parse_index(pd.Int64Index([])),
                columns_value=columns,
            )
            out_chunks.append(out_chunk)

    new_op = op.copy()
    return new_op.new_dataframes(
        op.inputs,
        out_df.shape,
        dtypes=out_df.dtypes,
        index_value=out_df.index_value,
        columns_value=out_df.columns,
        chunks=out_chunks,
        nsplits=in_df.nsplits,
    )


# 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 tile(cls, op):
    in_df = op.inputs[0]
    out_df = op.outputs[0]

    if not isinstance(op.keys, six.string_types):
        raise NotImplementedError("DataFrame.set_index only support label")
    if op.verify_integrity:
        raise NotImplementedError(
            "DataFrame.set_index not support verify_integrity yet"
        )

    out_chunks = []

    try:
        column_index = in_df.columns_value.to_pandas().get_loc(op.keys)
    except KeyError:
        raise NotImplementedError(
            "The new index label must be a column of the original dataframe"
        )

    chunk_index = np.searchsorted(np.cumsum(in_df.nsplits[1]), column_index + 1)

    for row_idx in range(in_df.chunk_shape[0]):
        index_chunk = in_df.cix[row_idx, chunk_index]
        for col_idx in range(in_df.chunk_shape[1]):
            input_chunk = in_df.cix[row_idx, col_idx]
            if op.drop and input_chunk.key == index_chunk.key:
                new_shape = (input_chunk.shape[0], input_chunk.shape[1] - 1)
                columns = parse_index(
                    input_chunk.columns_value.to_pandas().drop(op.keys), store_data=True
                )
            else:
                new_shape = input_chunk.shape
                columns = input_chunk.columns_value
            out_op = op.copy().reset_key()
            out_chunk = out_op.new_chunk(
                [index_chunk, input_chunk],
                shape=new_shape,
                dtypes=out_df.dtypes,
                index=input_chunk.index,
                index_value=parse_index(pd.Int64Index([])),
                columns_value=columns,
            )
            out_chunks.append(out_chunk)

    new_op = op.copy()
    return new_op.new_dataframes(
        op.inputs,
        out_df.shape,
        dtypes=out_df.dtypes,
        index_value=out_df.index_value,
        columns_value=out_df.columns_value,
        chunks=out_chunks,
        nsplits=in_df.nsplits,
    )