# Buggy code
def to_frame(self, index: bool = True, name=None):
    """
    Create a DataFrame with a column containing the Index.

    Parameters
    ----------
    index : bool, default True
        Set the index of the returned DataFrame as the original Index.

    name : object, default None
        The passed name should substitute for the index name (if it has
        one).

    Returns
    -------
    DataFrame
        DataFrame containing the original Index data.

    See Also
    --------
    Index.to_series : Convert an Index to a Series.
    Series.to_frame : Convert Series to DataFrame.

    Examples
    --------
    >>> import mars.dataframe as md
    >>> idx = md.Index(['Ant', 'Bear', 'Cow'], name='animal')
    >>> idx.to_frame().execute()
           animal
    animal
    Ant       Ant
    Bear     Bear
    Cow       Cow

    By default, the original Index is reused. To enforce a new Index:

    >>> idx.to_frame(index=False).execute()
      animal
    0    Ant
    1   Bear
    2    Cow

    To override the name of the resulting column, specify `name`:

    >>> idx.to_frame(index=False, name='zoo').execute()
        zoo
    0   Ant
    1  Bear
    2   Cow
    """
    from . import dataframe_from_tensor

    if isinstance(self.index_value.value, IndexValue.MultiIndex):
        old_names = self.index_value.value.names

        if name is not None and not isinstance(name, Iterable) or isinstance(name, str):
            raise TypeError("'name' must be a list / sequence of column names.")

        name = list(name if name is not None else old_names)
        if len(name) != len(old_names):
            raise ValueError(
                "'name' should have same length as number of levels on index."
            )

        columns = [
            old or new or idx for idx, (old, new) in enumerate(zip(old_names, name))
        ]
    else:
        columns = [name or self.name or 0]
    index_ = self if index else None
    return dataframe_from_tensor(
        self._to_mars_tensor(self, extract_multi_index=True),
        index=index_,
        columns=columns,
    )


# Traceback (ValueError)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-52-f2912f2e33a0> in <module>
1 from mars.learn.metrics import accuracy_score
----> 2 accuracy_score(y_test,y_pred).execute()

/home/tops/lib/python3.6/site-packages/mars/learn/metrics/_classification.py in accuracy_score(y_true, y_pred, normalize, sample_weight, session, run_kwargs)
178     op = AccuracyScore(y_true=y_true, y_pred=y_pred, normalize=normalize,
179                        sample_weight=sample_weight)
--> 180     score = op(y_true, y_pred)
181     return score.execute(session=session, **(run_kwargs or dict()))

/home/tops/lib/python3.6/site-packages/mars/utils.py in _inner(*args, **kwargs)
455         def _inner(*args, **kwargs):
456             with self:
--> 457                 return func(*args, **kwargs)
458
459         return _inner

/home/tops/lib/python3.6/site-packages/mars/learn/metrics/_classification.py in __call__(self, y_true, y_pred)
76
77     def __call__(self, y_true, y_pred):
---> 78         type_true, y_true, y_pred = _check_targets(y_true, y_pred)
79         self._type_true = type_true
80         inputs = [y_true, y_pred, type_true]

/home/tops/lib/python3.6/site-packages/mars/learn/metrics/_check_targets.py in _check_targets(y_true, y_pred)
193     """
194     op = CheckTargets(y_true=y_true, y_pred=y_pred)
--> 195     return op(y_true, y_pred)

/home/tops/lib/python3.6/site-packages/mars/utils.py in _inner(*args, **kwargs)
455         def _inner(*args, **kwargs):
456             with self:
--> 457                 return func(*args, **kwargs)
458
459         return _inner

/home/tops/lib/python3.6/site-packages/mars/learn/metrics/_check_targets.py in __call__(self, y_true, y_pred)
82         if isinstance(y_pred, (Base, Entity)):
83             inputs.append(y_pred)
---> 84         self._type_true = type_of_target(y_true)
85         self._type_pred = type_of_target(y_pred)
86         inputs.extend([self._type_true, self._type_pred])

/home/tops/lib/python3.6/site-packages/mars/learn/utils/multiclass.py in type_of_target(y)
403
404     if not valid:
--> 405         raise ValueError(f'Expected array-like (array or non-string sequence), got {y}')
406
407     sparse_pandas = (y.__class__.__name__ in ['SparseSeries', 'SparseArray'])

ValueError: Expected array-like (array or non-string sequence), got 159615    0
134010    0
199100    0
137756    0
200050    0
..
219880    0
82326     0
184439    0
198518    0
109959    0
Name: label_bigint, Length: 1146788, dtype: int64

# Fixed code
def to_frame(self, index: bool = True, name=None):
    """
    Create a DataFrame with a column containing the Index.

    Parameters
    ----------
    index : bool, default True
        Set the index of the returned DataFrame as the original Index.

    name : object, default None
        The passed name should substitute for the index name (if it has
        one).

    Returns
    -------
    DataFrame
        DataFrame containing the original Index data.

    See Also
    --------
    Index.to_series : Convert an Index to a Series.
    Series.to_frame : Convert Series to DataFrame.

    Examples
    --------
    >>> import mars.dataframe as md
    >>> idx = md.Index(['Ant', 'Bear', 'Cow'], name='animal')
    >>> idx.to_frame().execute()
           animal
    animal
    Ant       Ant
    Bear     Bear
    Cow       Cow

    By default, the original Index is reused. To enforce a new Index:

    >>> idx.to_frame(index=False).execute()
      animal
    0    Ant
    1   Bear
    2    Cow

    To override the name of the resulting column, specify `name`:

    >>> idx.to_frame(index=False, name='zoo').execute()
        zoo
    0   Ant
    1  Bear
    2   Cow
    """
    from . import dataframe_from_tensor

    if isinstance(self.index_value.value, IndexValue.MultiIndex):
        old_names = self.index_value.value.names

        if name is not None and not isinstance(name, Iterable) or isinstance(name, str):
            raise TypeError("'name' must be a list / sequence of column names.")

        name = list(name if name is not None else old_names)
        if len(name) != len(old_names):
            raise ValueError(
                "'name' should have same length as number of levels on index."
            )

        columns = [
            old or new or idx for idx, (old, new) in enumerate(zip(old_names, name))
        ]
    else:
        columns = [name or self.name or 0]
    index_ = self if index else None
    return dataframe_from_tensor(
        self._data._to_mars_tensor(self, extract_multi_index=True),
        index=index_,
        columns=columns,
    )