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

    if op.from_1d_tensors:
        d = OrderedDict()
        tensors = [ctx[inp.key] for inp in op.inputs]
        if op.index is not None:
            tensors_data, index_data = tensors[:-1], tensors[-1]
        else:
            tensors_data = tensors
            index_data = chunk.index_value.to_pandas()
        for name, data_1d in zip(chunk.dtypes.index, tensors_data):
            d[name] = data_1d
        ctx[chunk.key] = pd.DataFrame(
            d, index=index_data, columns=chunk.columns_value.to_pandas()
        )
    else:
        tensor_data = ctx[op.inputs[0].key]
        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()
        ctx[chunk.key] = pd.DataFrame(
            tensor_data, index=index_data, columns=chunk.columns_value.to_pandas()
        )


# Traceback (ValueError)
In [7]: md.DataFrame({'a': '1', 'b': md.Series([1, 2, 3])}).execute()
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-7-ec6db392e00f> in <module>
----> 1 md.DataFrame({'a': '1', 'b': md.Series([1, 2, 3])}).execute()

~/Workspace/mars/mars/dataframe/initializer.py in __init__(self, data, index, columns, dtype, copy, chunk_size, gpu, sparse)
46             df = dataframe_from_1d_tensors(
47                 tensors, index=index, columns=columns,
---> 48                 gpu=gpu, sparse=sparse)
49         else:
50             pdf = pd.DataFrame(data, index=index, columns=columns, dtype=dtype, copy=copy)

~/Workspace/mars/mars/dataframe/datasource/from_tensor.py in dataframe_from_1d_tensors(tensors, index, columns, gpu, sparse)
328     op = DataFrameFromTensor(dtypes=dtypes, from_1d_tensors=True,
329                              gpu=gpu, sparse=sparse)
--> 330     return op(tensors, index, columns)
331
332

~/Workspace/mars/mars/dataframe/datasource/from_tensor.py in __call__(self, input_tensor, index, columns)
73     def __call__(self, input_tensor, index, columns):
74         if self._from_1d_tensors:
---> 75             return self._call_input_1d_tensors(input_tensor, index, columns)
76         else:
77             return self._call_input_tensor(input_tensor, index, columns)

~/Workspace/mars/mars/dataframe/datasource/from_tensor.py in _call_input_1d_tensors(self, input_1d_tensors, index, columns)
99     def _call_input_1d_tensors(self, input_1d_tensors, index, columns):
100         if len({t.shape for t in input_1d_tensors}) != 1:
--> 101             raise ValueError('input 1-d tensors should have same shape')
102
103         inputs = list(input_1d_tensors)

ValueError: input 1-d tensors should have same shape

# 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()
        )
    else:
        tensor_data = ctx[op.inputs[0].key]
        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()
        ctx[chunk.key] = pd.DataFrame(
            tensor_data, index=index_data, columns=chunk.columns_value.to_pandas()
        )