# Buggy code
def process(self, index_info: IndexInfo, context: IndexHandlerContext) -> None:
    tileable = context.tileable
    input_axis = index_info.input_axis
    is_first_bool_index = self._is_first_bool_index(context, index_info)

    axes = list(range(input_axis, input_axis + index_info.raw_index.ndim))
    cum_sizes = []
    for axis in axes:
        cum_sizes.append(np.cumsum((0,) + tileable.nsplits[axis]))

    other_index_to_iter = dict()
    for chunk_index, chunk_index_info in context.chunk_index_to_info.items():
        slcs = []
        for j, axis in enumerate(axes):
            axis_index = chunk_index[axis]
            slcs.append(slice(cum_sizes[j][axis_index], cum_sizes[j][axis_index + 1]))
        other_index = chunk_index[: axes[0]] + chunk_index[axes[-1] + 1 :]
        if other_index not in other_index_to_iter:
            other_index_to_iter[other_index] = itertools.count()
        index = index_info.raw_index[tuple(slcs)]
        output_axis_index = next(other_index_to_iter[other_index])

        # if more than 1 bool index, getitem will rewrite them into fancy
        # but for now, setitem will keep them, thus we cannot record
        # index or shape for this one
        output_axis_index = None if not is_first_bool_index else output_axis_index
        output_size = None if not is_first_bool_index else index.sum()

        self.set_chunk_index_info(
            context,
            index_info,
            chunk_index,
            chunk_index_info,
            output_axis_index,
            index,
            output_size,
        )


# Traceback (AttributeError)
In [3]: import pandas as pd

In [4]: data = pd.DataFrame(np.arange(20).reshape((4, 5)) + 1, columns=['a', 'b', 'c', 'd', 'e'])

In [6]: df = md.DataFrame(data)

In [7]: df.groupby(['a','b']).size().execute()
Unexpected exception occurred in enter_build_mode.<locals>.inner.
Traceback (most recent call last):
File "/Users/hekaisheng/Documents/mars_dev/mars/mars/utils.py", line 353, in _wrapped
return func(*args, **kwargs)
File "/Users/hekaisheng/Documents/mars_dev/mars/mars/utils.py", line 493, in inner
return func(*args, **kwargs)
File "/Users/hekaisheng/Documents/mars_dev/mars/mars/scheduler/graph.py", line 633, in prepare_graph
self._target_tileable_datas + fetch_tileables, tileable_graph)
File "/Users/hekaisheng/Documents/mars_dev/mars/mars/utils.py", line 399, in _wrapped
return func(*args, **kwargs)
File "/Users/hekaisheng/Documents/mars_dev/mars/mars/utils.py", line 493, in inner
return func(*args, **kwargs)
File "/Users/hekaisheng/Documents/mars_dev/mars/mars/tiles.py", line 350, in build
tileables, tileable_graph=tileable_graph)
File "/Users/hekaisheng/Documents/mars_dev/mars/mars/utils.py", line 399, in _wrapped
return func(*args, **kwargs)
File "/Users/hekaisheng/Documents/mars_dev/mars/mars/utils.py", line 493, in inner
return func(*args, **kwargs)
File "/Users/hekaisheng/Documents/mars_dev/mars/mars/tiles.py", line 263, in build
self._on_tile_failure(tileable_data.op, exc_info)
File "/Users/hekaisheng/Documents/mars_dev/mars/mars/tiles.py", line 302, in inner
raise exc_info[1].with_traceback(exc_info[2]) from None
File "/Users/hekaisheng/Documents/mars_dev/mars/mars/tiles.py", line 243, in build
tiled = self._tile(tileable_data, tileable_graph)
File "/Users/hekaisheng/Documents/mars_dev/mars/mars/tiles.py", line 338, in _tile
return super()._tile(tileable_data, tileable_graph)
File "/Users/hekaisheng/Documents/mars_dev/mars/mars/tiles.py", line 203, in _tile
tds = on_tile(tileable_data.op.outputs, tds)
File "/Users/hekaisheng/Documents/mars_dev/mars/mars/scheduler/graph.py", line 615, in on_tile
return self.context.wraps(handler.dispatch)(first.op)
File "/Users/hekaisheng/Documents/mars_dev/mars/mars/context.py", line 69, in h
return func(*args, **kwargs)
File "/Users/hekaisheng/Documents/mars_dev/mars/mars/utils.py", line 399, in _wrapped
return func(*args, **kwargs)
File "/Users/hekaisheng/Documents/mars_dev/mars/mars/tiles.py", line 119, in dispatch
tiled = op_cls.tile(op)
File "/Users/hekaisheng/Documents/mars_dev/mars/mars/dataframe/groupby/aggregation.py", line 481, in tile
return cls._tile_with_tree(op)
File "/Users/hekaisheng/Documents/mars_dev/mars/mars/dataframe/groupby/aggregation.py", line 412, in _tile_with_tree
index = out_df.index_value.to_pandas()
File "/Users/hekaisheng/Documents/mars_dev/mars/mars/dataframe/core.py", line 283, in to_pandas
return self._index_value.to_pandas()
File "/Users/hekaisheng/Documents/mars_dev/mars/mars/dataframe/core.py", line 197, in to_pandas
sortorder=self._sortorder, names=self._names)
AttributeError: _sortorder

# Fixed code
def process(self, index_info: IndexInfo, context: IndexHandlerContext) -> None:
    tileable = context.tileable
    input_axis = index_info.input_axis
    is_first_bool_index = self._is_first_bool_index(context, index_info)

    axes = list(range(input_axis, input_axis + index_info.raw_index.ndim))
    cum_sizes = []
    for axis in axes:
        cum_sizes.append(np.cumsum((0,) + tileable.nsplits[axis]))

    other_index_to_iter = dict()
    for chunk_index, chunk_index_info in context.chunk_index_to_info.items():
        slcs = []
        for j, axis in enumerate(axes):
            axis_index = chunk_index[axis]
            slcs.append(slice(cum_sizes[j][axis_index], cum_sizes[j][axis_index + 1]))
        other_index = chunk_index[: axes[0]] + chunk_index[axes[-1] + 1 :]
        if other_index not in other_index_to_iter:
            other_index_to_iter[other_index] = itertools.count()
        index = index_info.raw_index[tuple(slcs)]
        output_axis_index = next(other_index_to_iter[other_index])

        # if more than 1 bool index, getitem will rewrite them into fancy
        # but for now, setitem will keep them, thus we cannot record
        # index or shape for this one
        output_axis_index = None if not is_first_bool_index else output_axis_index
        output_size = None if not is_first_bool_index else int(index.sum())

        self.set_chunk_index_info(
            context,
            index_info,
            chunk_index,
            chunk_index_info,
            output_axis_index,
            index,
            output_size,
        )