# Buggy code
def default_to_pandas(self, pandas_op, *args, **kwargs):
    """Default to pandas behavior.

    Parameters
    ----------
    pandas_op : callable
        The operation to apply, must be compatible pandas DataFrame call
    args
        The arguments for the `pandas_op`
    kwargs
        The keyword arguments for the `pandas_op`

    Returns
    -------
    PandasQueryCompiler
        The result of the `pandas_op`, converted back to PandasQueryCompiler

    Note
    ----
    This operation takes a distributed object and converts it directly to pandas.
    """
    ErrorMessage.default_to_pandas(str(pandas_op))
    args = (a.to_pandas() if isinstance(a, type(self)) else a for a in args)
    kwargs = {
        k: v.to_pandas if isinstance(v, type(self)) else v for k, v in kwargs.items()
    }
    return self.from_pandas(
        pandas_op(self.to_pandas(), *args, **kwargs), type(self._modin_frame)
    )


# Traceback (Exception)
'Traceback (most recent call last):\n
File "/home/adrian.arroyo/.vscode-server/extensions/ms-python.python-2020.5.80290/pythonFiles/lib/python/debugpy/no_wheels/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_resolver.py", line 193, in _get_py_dictionary\n
attr = getattr(var, name)\n
File "/home/adrian.arroyo/.local/lib/python3.6/site-packages/modin/pandas/base.py", line 3381, in __getattribute__\n
method = object.__getattribute__(self, item)\n
File "/home/adrian.arroyo/.local/lib/python3.6/site-packages/modin/pandas/series.py", line 349, in values\n
return super(Series, self).to_numpy().flatten()\n
File "/home/adrian.arroyo/.local/lib/python3.6/site-packages/modin/pandas/base.py", line 2981, in to_numpy\n
arr = self._query_compiler.to_numpy()\n
File "/home/adrian.arroyo/.local/lib/python3.6/site-packages/modin/backends/pandas/query_compiler.py", line 182, in to_numpy\n
len(arr) != len(self.index) or len(arr[0]) != len(self.columns)\n
File "/home/adrian.arroyo/.local/lib/python3.6/site-packages/modin/error_message.py", line 53, in catch_bugs_and_request_email\n
" caused this error.\\n{}".format(extra_log)\n
Exception: Internal Error. Please email bug_reports@modin.org with the traceback and command that caused this error.\n\n'

# Fixed code
def default_to_pandas(self, pandas_op, *args, **kwargs):
    """Default to pandas behavior.

    Parameters
    ----------
    pandas_op : callable
        The operation to apply, must be compatible pandas DataFrame call
    args
        The arguments for the `pandas_op`
    kwargs
        The keyword arguments for the `pandas_op`

    Returns
    -------
    PandasQueryCompiler
        The result of the `pandas_op`, converted back to PandasQueryCompiler

    Note
    ----
    This operation takes a distributed object and converts it directly to pandas.
    """
    ErrorMessage.default_to_pandas(str(pandas_op))
    args = (a.to_pandas() if isinstance(a, type(self)) else a for a in args)
    kwargs = {
        k: v.to_pandas if isinstance(v, type(self)) else v for k, v in kwargs.items()
    }

    result = pandas_op(self.to_pandas(), *args, **kwargs)
    if isinstance(result, pandas.Series):
        result = result.to_frame()
    if isinstance(result, pandas.DataFrame):
        return self.from_pandas(result, type(self._modin_frame))
    else:
        return result