# Buggy code
def execute(cls, ctx, op):
    chunk = op.outputs[0]

    if isinstance(op.input, dict):
        d = OrderedDict()
        for k, v in op.input.items():
            if hasattr(v, "key"):
                d[k] = ctx[v.key]
            else:
                d[k] = v
        if op.index is not None:
            index_data = ctx[op.index.key]
        else:
            index_data = chunk.index_value.to_pandas()
        ctx[chunk.key] = pd.DataFrame(
            d, index=index_data, columns=chunk.columns_value.to_pandas()
        )
    else:
        tensor_data = ctx[op.inputs[0].key]
        if isinstance(tensor_data, pd.Series):
            ctx[chunk.key] = tensor_data.to_frame(name=chunk.dtypes.index[0])
        else:
            if op.index is not None:
                # index is a tensor
                index_data = ctx[op.inputs[1].key]
            else:
                index_data = chunk.index_value.to_pandas()
                if isinstance(index_data, pd.RangeIndex) and len(index_data) == 0:
                    index_data = None
            ctx[chunk.key] = pd.DataFrame(
                tensor_data, index=index_data, columns=chunk.columns_value.to_pandas()
            )


# Traceback (NotImplementedError)
In [52]: df = md.DataFrame(index=[1, 2, 3])

In [53]: df['a'] = md.Series(['a', 'b', 'c'], index=[2, 3, 4])
---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
<ipython-input-53-f550a59ef82c> in <module>
----> 1 df['a'] = md.Series(['a', 'b', 'c'], index=[2, 3, 4])

~/Workspace/mars/mars/dataframe/indexing/setitem.py in dataframe_setitem(df, col, value)
182 def dataframe_setitem(df, col, value):
183     op = DataFrameSetitem(target=df, indexes=col, value=value)
--> 184     return op(df, value)

~/Workspace/mars/mars/utils.py in _inner(*args, **kwargs)
457         @functools.wraps(func)
458         def _inner(*args, **kwargs):
--> 459             with self:
460                 return func(*args, **kwargs)
461

~/Workspace/mars/mars/dataframe/indexing/setitem.py in __call__(self, target, value)
83
84             if value.index_value.key != target.index_value.key:  # pragma: no cover
---> 85                 raise NotImplementedError('Does not support setting value '
86                                           'with different index for now')
87

NotImplementedError: Does not support setting value with different index for now

# Fixed code
def execute(cls, ctx, op):
    chunk = op.outputs[0]

    if isinstance(op.input, dict):
        d = OrderedDict()
        for k, v in op.input.items():
            if hasattr(v, "key"):
                d[k] = ctx[v.key]
            else:
                d[k] = v
        if op.index is not None:
            index_data = ctx[op.index.key]
        else:
            index_data = chunk.index_value.to_pandas()
        ctx[chunk.key] = pd.DataFrame(
            d, index=index_data, columns=chunk.columns_value.to_pandas()
        )
    elif op.input is not None:
        tensor_data = ctx[op.inputs[0].key]
        if isinstance(tensor_data, pd.Series):
            ctx[chunk.key] = tensor_data.to_frame(name=chunk.dtypes.index[0])
        else:
            if op.index is not None:
                # index is a tensor
                index_data = ctx[op.inputs[1].key]
            else:
                index_data = chunk.index_value.to_pandas()
                if isinstance(index_data, pd.RangeIndex) and len(index_data) == 0:
                    index_data = None
            ctx[chunk.key] = pd.DataFrame(
                tensor_data, index=index_data, columns=chunk.columns_value.to_pandas()
            )
    else:
        index_data = ctx[op.index.key]
        ctx[chunk.key] = pd.DataFrame(
            index=index_data, columns=chunk.columns_value.to_pandas()
        )