# Buggy code
def _call_dataframe(self, df, dtypes=None, index=None):
    dtypes, index_value = self._infer_df_func_returns(df, dtypes, index)
    for arg, desc in zip(
        (self.output_types, dtypes, index_value), ("output_types", "dtypes", "index")
    ):
        if arg is None:
            raise TypeError(
                f"Cannot determine {desc} by calculating with enumerate data, "
                "please specify it as arguments"
            )

    if index_value == "inherit":
        index_value = df.index_value

    if self._elementwise:
        shape = df.shape
    elif self.output_types[0] == OutputType.dataframe:
        shape = [np.nan, np.nan]
        shape[1 - self.axis] = df.shape[1 - self.axis]
        shape = tuple(shape)
    else:
        shape = (df.shape[1 - self.axis],)

    if self.output_types[0] == OutputType.dataframe:
        if self.axis == 0:
            return self.new_dataframe(
                [df],
                shape=shape,
                dtypes=dtypes,
                index_value=index_value,
                columns_value=parse_index(dtypes.index),
            )
        else:
            return self.new_dataframe(
                [df],
                shape=shape,
                dtypes=dtypes,
                index_value=df.index_value,
                columns_value=parse_index(dtypes.index),
            )
    else:
        return self.new_series([df], shape=shape, dtype=dtypes, index_value=index_value)


# Traceback (AssertionError)
Traceback (most recent call last):
File "/Users/wenjun/miniconda3/lib/python3.8/unittest/case.py", line 60, in testPartExecutor
yield
File "/Users/wenjun/miniconda3/lib/python3.8/unittest/case.py", line 676, in run
self._callTestMethod(testMethod)
File "/Users/wenjun/miniconda3/lib/python3.8/unittest/case.py", line 633, in _callTestMethod
method()
File "/Users/wenjun/Code/mars/mars/dataframe/groupby/tests/test_groupby_execution.py", line 401, in testGroupByApply
pd.testing.assert_frame_equal(self.executor.execute_dataframe(applied, concat=True)[0],
File "/Users/wenjun/Code/mars/mars/tests/core.py", line 686, in execute_tileable
result = super().execute_tileable(tileable, *args, **kwargs)
File "/Users/wenjun/Code/mars/mars/utils.py", line 439, in _inner
return func(*args, **kwargs)
File "/Users/wenjun/Code/mars/mars/executor.py", line 720, in execute_tileable
ret = self.execute_graph(chunk_graph, result_keys, n_parallel=n_parallel or n_thread,
File "/Users/wenjun/Code/mars/mars/tests/core.py", line 673, in execute_graph
return super().execute_graph(graph, keys, **kw)
File "/Users/wenjun/Code/mars/mars/executor.py", line 693, in execute_graph
res = graph_execution.execute(retval)
File "/Users/wenjun/Code/mars/mars/executor.py", line 574, in execute
future.result()
File "/Users/wenjun/miniconda3/lib/python3.8/concurrent/futures/_base.py", line 439, in result
return self.__get_result()
File "/Users/wenjun/miniconda3/lib/python3.8/concurrent/futures/_base.py", line 388, in __get_result
raise self._exception
File "/Users/wenjun/miniconda3/lib/python3.8/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/Users/wenjun/Code/mars/mars/tests/core.py", line 591, in _execute_operand
super()._execute_operand(op)
File "/Users/wenjun/Code/mars/mars/utils.py", line 439, in _inner
return func(*args, **kwargs)
File "/Users/wenjun/Code/mars/mars/executor.py", line 446, in _execute_operand
self.handle_op(first_op, results, self._mock)
File "/Users/wenjun/Code/mars/mars/executor.py", line 378, in handle_op
return Executor.handle(*args, **kw)
File "/Users/wenjun/Code/mars/mars/executor.py", line 644, in handle
return runner(results, op)
File "/Users/wenjun/Code/mars/mars/dataframe/groupby/apply.py", line 63, in execute
assert len(applied.index) == 1
AssertionError

# Fixed code
def _call_dataframe(self, df, dtypes=None, index=None):
    dtypes, index_value = self._infer_df_func_returns(df, dtypes, index)
    if index_value is None:
        index_value = parse_index(None, (df.key, df.index_value.key))
    for arg, desc in zip((self.output_types, dtypes), ("output_types", "dtypes")):
        if arg is None:
            raise TypeError(
                f"Cannot determine {desc} by calculating with enumerate data, "
                "please specify it as arguments"
            )

    if index_value == "inherit":
        index_value = df.index_value

    if self._elementwise:
        shape = df.shape
    elif self.output_types[0] == OutputType.dataframe:
        shape = [np.nan, np.nan]
        shape[1 - self.axis] = df.shape[1 - self.axis]
        shape = tuple(shape)
    else:
        shape = (df.shape[1 - self.axis],)

    if self.output_types[0] == OutputType.dataframe:
        if self.axis == 0:
            return self.new_dataframe(
                [df],
                shape=shape,
                dtypes=dtypes,
                index_value=index_value,
                columns_value=parse_index(dtypes.index),
            )
        else:
            return self.new_dataframe(
                [df],
                shape=shape,
                dtypes=dtypes,
                index_value=df.index_value,
                columns_value=parse_index(dtypes.index),
            )
    else:
        return self.new_series([df], shape=shape, dtype=dtypes, index_value=index_value)