# Buggy code
def __call__(self, shape=None, chunk_size=None, inp=None, name=None, names=None):
    if inp is None:
        # create from pandas Index
        name = name if name is not None else self._data.name
        return self.new_index(
            None,
            shape=shape,
            dtype=self._dtype,
            index_value=parse_index(self._data),
            name=name,
            raw_chunk_size=chunk_size,
        )
    elif hasattr(inp, "index_value"):
        # get index from Mars DataFrame, Series or Index
        name = name if name is not None else inp.index_value.name
        names = names if names is not None else [name]
        if inp.index_value.has_value():
            self._data = data = inp.index_value.to_pandas()
            return self.new_index(
                None,
                shape=(inp.shape[0],),
                dtype=data.dtype,
                index_value=parse_index(data),
                name=name,
                names=names,
                raw_chunk_size=chunk_size,
            )
        else:
            if self._dtype is None:
                self._dtype = inp.index_value.to_pandas().dtype
            return self.new_index(
                [inp],
                shape=(inp.shape[0],),
                dtype=self._dtype,
                index_value=inp.index_value,
                name=name,
                names=names,
            )
    else:
        if inp.ndim != 1:
            raise ValueError("Index data must be 1-dimensional")
        # get index from tensor
        dtype = inp.dtype if self._dtype is None else self._dtype
        pd_index = pd.Index([], dtype=dtype)
        if self._dtype is None:
            self._dtype = pd_index.dtype
        return self.new_index(
            [inp],
            shape=inp.shape,
            dtype=self._dtype,
            index_value=parse_index(pd_index, inp),
            name=name,
        )


# Traceback (ZeroDivisionError)
Traceback (most recent call last):
File "/Users/wenjun.swj/miniconda3/lib/python3.8/site-packages/IPython/core/interactiveshell.py", line 3417, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-6-f86c22f8381d>", line 1, in <module>
mdf[mdf[0] != 0].sort_values(0).execute()
File "/Users/wenjun.swj/Code/mars/mars/core.py", line 646, in execute
return run()
File "/Users/wenjun.swj/Code/mars/mars/core.py", line 642, in run
self.data.execute(session, **kw)
File "/Users/wenjun.swj/Code/mars/mars/core.py", line 379, in execute
return run()
File "/Users/wenjun.swj/Code/mars/mars/core.py", line 374, in run
session.run(self, **kw)
File "/Users/wenjun.swj/Code/mars/mars/session.py", line 505, in run
result = self._sess.run(*tileables, **kw)
File "/Users/wenjun.swj/Code/mars/mars/session.py", line 111, in run
res = self._executor.execute_tileables(tileables, **kw)
File "/Users/wenjun.swj/Code/mars/mars/utils.py", line 457, in _inner
return func(*args, **kwargs)
File "/Users/wenjun.swj/Code/mars/mars/executor.py", line 883, in execute_tileables
self.execute_graph(chunk_graph, list(temp_result_keys),
File "/Users/wenjun.swj/Code/mars/mars/executor.py", line 698, in execute_graph
res = graph_execution.execute(retval)
File "/Users/wenjun.swj/Code/mars/mars/executor.py", line 579, in execute
future.result()
File "/Users/wenjun.swj/miniconda3/lib/python3.8/concurrent/futures/_base.py", line 432, in result
return self.__get_result()
File "/Users/wenjun.swj/miniconda3/lib/python3.8/concurrent/futures/_base.py", line 388, in __get_result
raise self._exception
File "/Users/wenjun.swj/miniconda3/lib/python3.8/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/Users/wenjun.swj/Code/mars/mars/utils.py", line 457, in _inner
return func(*args, **kwargs)
File "/Users/wenjun.swj/Code/mars/mars/executor.py", line 446, in _execute_operand
self.handle_op(first_op, results, self._mock)
File "/Users/wenjun.swj/Code/mars/mars/executor.py", line 378, in handle_op
return Executor.handle(*args, **kw)
File "/Users/wenjun.swj/Code/mars/mars/executor.py", line 649, in handle
return runner(results, op)
File "/Users/wenjun.swj/Code/mars/mars/dataframe/sort/psrs.py", line 355, in execute
num = n // a.shape[op.axis] + 1
ZeroDivisionError: integer division or modulo by zero

# Fixed code
def __call__(self, shape=None, chunk_size=None, inp=None, name=None, names=None):
    if inp is None:
        # create from pandas Index
        name = name if name is not None else self._data.name
        names = names if names is not None else self._data.names
        return self.new_index(
            None,
            shape=shape,
            dtype=self._dtype,
            index_value=parse_index(self._data),
            name=name,
            names=names,
            raw_chunk_size=chunk_size,
        )
    elif hasattr(inp, "index_value"):
        # get index from Mars DataFrame, Series or Index
        name = name if name is not None else inp.index_value.name
        names = names if names is not None else [name]
        if inp.index_value.has_value():
            self._data = data = inp.index_value.to_pandas()
            return self.new_index(
                None,
                shape=(inp.shape[0],),
                dtype=data.dtype,
                index_value=parse_index(data),
                name=name,
                names=names,
                raw_chunk_size=chunk_size,
            )
        else:
            if self._dtype is None:
                self._dtype = inp.index_value.to_pandas().dtype
            return self.new_index(
                [inp],
                shape=(inp.shape[0],),
                dtype=self._dtype,
                index_value=inp.index_value,
                name=name,
                names=names,
            )
    else:
        if inp.ndim != 1:
            raise ValueError("Index data must be 1-dimensional")
        # get index from tensor
        dtype = inp.dtype if self._dtype is None else self._dtype
        pd_index = pd.Index([], dtype=dtype)
        if self._dtype is None:
            self._dtype = pd_index.dtype
        return self.new_index(
            [inp],
            shape=inp.shape,
            dtype=self._dtype,
            index_value=parse_index(pd_index, inp),
            name=name,
            names=names,
        )