# Buggy code
def _scalar_operations(self, axis, scalar, func):
    """Handler for mapping scalar operations across a Manager.

    Args:
        axis: The axis index object to execute the function on.
        scalar: The scalar value to map.
        func: The function to use on the Manager with the scalar.

    Returns:
        A new QueryCompiler with updated data and new index.
    """
    if isinstance(scalar, (list, np.ndarray, pandas.Series)):
        new_index = self.index if axis == 0 else self.columns

        def list_like_op(df):
            if axis == 0:
                df.index = new_index
            else:
                df.columns = new_index
            return func(df)

        new_data = self._map_across_full_axis(axis, self._prepare_method(list_like_op))
        return self.__constructor__(new_data, self.index, self.columns)
    else:
        return self._map_partitions(self._prepare_method(func))


# Traceback (Exception)
---------------------------------------------------------------------------
Exception                                 Traceback (most recent call last)
~/Documents/modin/venv/lib/python3.6/site-packages/IPython/core/formatters.py in __call__(self, obj)
700                 type_pprinters=self.type_printers,
701                 deferred_pprinters=self.deferred_printers)
--> 702             printer.pretty(obj)
703             printer.flush()
704             return stream.getvalue()

~/Documents/modin/venv/lib/python3.6/site-packages/IPython/lib/pretty.py in pretty(self, obj)
400                         if cls is not object \
401                                 and callable(cls.__dict__.get('__repr__')):
--> 402                             return _repr_pprint(obj, self, cycle)
403
404             return _default_pprint(obj, self, cycle)

~/Documents/modin/venv/lib/python3.6/site-packages/IPython/lib/pretty.py in _repr_pprint(obj, p, cycle)
695     """A pprint that just redirects to the normal repr function."""
696     # Find newlines and replace them with p.break_()
--> 697     output = repr(obj)
698     for idx,output_line in enumerate(output.splitlines()):
699         if idx:

~/Documents/modin/modin/pandas/dataframe.py in __repr__(self)
91         num_cols = pandas.get_option("max_columns") or 20
92
---> 93         result = repr(self._build_repr_df(num_rows, num_cols))
94         if len(self.index) > num_rows or len(self.columns) > num_cols:
95             # The split here is so that we don't repr pandas row lengths.

~/Documents/modin/modin/pandas/base.py in _build_repr_df(self, num_rows, num_cols)
59
60         if not hasattr(self, "columns") or len(self.columns) <= num_cols:
---> 61             head_front = head.to_pandas()
62             # Creating these empty to make the concat logic simpler
63             head_back = pandas.DataFrame()

~/Documents/modin/modin/backends/pandas/query_compiler.py in to_pandas(self)
507         else:
508             ErrorMessage.catch_bugs_and_request_email(
--> 509                 len(df.index) != len(self.index) or len(df.columns) != len(self.columns)
510             )
511             df.index = self.index

~/Documents/modin/modin/error_message.py in catch_bugs_and_request_email(cls, failure_condition)
36         if failure_condition:
37             raise Exception(
---> 38                 "Internal Error. "
39                 "Please email bug_reports@modin.org with the traceback and command that"
40                 " caused this error."

Exception: Internal Error. Please email bug_reports@modin.org with the traceback and command that caused this error.

---------------------------------------------------------------------------
Exception                                 Traceback (most recent call last)
~/Documents/modin/venv/lib/python3.6/site-packages/IPython/core/formatters.py in __call__(self, obj)
343             method = get_real_method(obj, self.print_method)
344             if method is not None:
--> 345                 return method()
346             return None
347         else:

~/Documents/modin/modin/pandas/dataframe.py in _repr_html_(self)
112         # We use pandas _repr_html_ to get a string of the HTML representation
113         # of the dataframe.
--> 114         result = self._build_repr_df(num_rows, num_cols)._repr_html_()
115         if len(self.index) > num_rows or len(self.columns) > num_cols:
116             # We split so that we insert our correct dataframe dimensions.

~/Documents/modin/modin/pandas/base.py in _build_repr_df(self, num_rows, num_cols)
59
60         if not hasattr(self, "columns") or len(self.columns) <= num_cols:
---> 61             head_front = head.to_pandas()
62             # Creating these empty to make the concat logic simpler
63             head_back = pandas.DataFrame()

~/Documents/modin/modin/backends/pandas/query_compiler.py in to_pandas(self)
507         else:
508             ErrorMessage.catch_bugs_and_request_email(
--> 509                 len(df.index) != len(self.index) or len(df.columns) != len(self.columns)
510             )
511             df.index = self.index

~/Documents/modin/modin/error_message.py in catch_bugs_and_request_email(cls, failure_condition)
36         if failure_condition:
37             raise Exception(
---> 38                 "Internal Error. "
39                 "Please email bug_reports@modin.org with the traceback and command that"
40                 " caused this error."

Exception: Internal Error. Please email bug_reports@modin.org with the traceback and command that caused this error.

# Fixed code
def _scalar_operations(self, axis, scalar, func):
    """Handler for mapping scalar operations across a Manager.

    Args:
        axis: The axis index object to execute the function on.
        scalar: The scalar value to map.
        func: The function to use on the Manager with the scalar.

    Returns:
        A new QueryCompiler with updated data and new index.
    """
    if isinstance(scalar, (list, np.ndarray, pandas.Series)):
        new_index = self.index if axis == 0 else self.columns

        def list_like_op(df):
            if axis == 0:
                df.index = new_index
            else:
                df.columns = new_index
            return func(df)

        new_data = self._map_across_full_axis(axis, self._prepare_method(list_like_op))
        if axis == 1 and isinstance(scalar, pandas.Series):
            new_columns = self.columns.union(
                [label for label in scalar.index if label not in self.columns]
            )
        else:
            new_columns = self.columns
        return self.__constructor__(new_data, self.index, new_columns)
    else:
        return self._map_partitions(self._prepare_method(func))