# Buggy code
def max_min_col_update(self):
    """Determines the maximum and minimum number in each column"""
    max_r = self.df.max(numeric_only=True)
    min_r = self.df.min(numeric_only=True)
    self.max_min_col = list(zip(max_r, min_r))
    if len(self.max_min_col) != self.df.shape[1]:
        # Then it contain complex numbers or other types
        float_intran = self.df.applymap(lambda e: isinstance(e, _sup_nr))
        self.complex_intran = self.df.applymap(lambda e: isinstance(e, _sup_com))
        mask = float_intran & (~self.complex_intran)
        try:
            df_abs = self.df[self.complex_intran].abs()
        except TypeError:
            df_abs = self.df[self.complex_intran]
        max_c = df_abs.max(skipna=True)
        min_c = df_abs.min(skipna=True)
        df_real = self.df[mask]
        max_r = df_real.max(skipna=True)
        min_r = df_real.min(skipna=True)
        self.max_min_col = list(
            zip(
                DataFrame([max_c, max_r]).max(skipna=True),
                DataFrame([min_c, min_r]).min(skipna=True),
            )
        )
    self.max_min_col = [
        [vmax, vmin - 1] if vmax == vmin else [vmax, vmin]
        for vmax, vmin in self.max_min_col
    ]


# Traceback (TypeError)
Spyder Internal Console

This console is used to report application
internal errors and to inspect Spyder
internals with the following commands:
spy.app, spy.window, dir(spy)

Please don't use it to run your code

/home/george/anaconda/lib/python2.7/site-packages/nbformat/current.py:19: UserWarning: nbformat.current is deprecated.

- use nbformat for read/write/validate public API
- use nbformat.vX directly to composing notebooks of a particular version

""")
Traceback (most recent call last):
File "/home/george/anaconda/lib/python2.7/site-packages/spyderlib/widgets/dicteditor.py", line 503, in createEditor
if not editor.setup_and_check(value, title=key):
File "/home/george/anaconda/lib/python2.7/site-packages/spyderlib/widgets/dataframeeditor.py", line 494, in setup_and_check
self.dataModel = DataFrameModel(data, parent=self)
File "/home/george/anaconda/lib/python2.7/site-packages/spyderlib/widgets/dataframeeditor.py", line 90, in __init__
self.max_min_col_update()
File "/home/george/anaconda/lib/python2.7/site-packages/spyderlib/widgets/dataframeeditor.py", line 124, in max_min_col_update
mask = float_intran &amp; (~ self.complex_intran)
File "/home/george/anaconda/lib/python2.7/site-packages/pandas/core/generic.py", line 639, in __invert__
arr = operator.inv(_values_from_object(self))
TypeError: ufunc 'invert' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
Traceback (most recent call last):
File "/home/george/anaconda/lib/python2.7/site-packages/spyderlib/widgets/dicteditor.py", line 503, in createEditor
if not editor.setup_and_check(value, title=key):
File "/home/george/anaconda/lib/python2.7/site-packages/spyderlib/widgets/dataframeeditor.py", line 494, in setup_and_check
self.dataModel = DataFrameModel(data, parent=self)
File "/home/george/anaconda/lib/python2.7/site-packages/spyderlib/widgets/dataframeeditor.py", line 90, in __init__
self.max_min_col_update()
File "/home/george/anaconda/lib/python2.7/site-packages/spyderlib/widgets/dataframeeditor.py", line 124, in max_min_col_update
mask = float_intran &amp; (~ self.complex_intran)
File "/home/george/anaconda/lib/python2.7/site-packages/pandas/core/generic.py", line 639, in __invert__
arr = operator.inv(_values_from_object(self))
TypeError: ufunc 'invert' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
Traceback (most recent call last):
File "/home/george/anaconda/lib/python2.7/site-packages/spyderlib/widgets/dicteditor.py", line 503, in createEditor
if not editor.setup_and_check(value, title=key):
File "/home/george/anaconda/lib/python2.7/site-packages/spyderlib/widgets/dataframeeditor.py", line 494, in setup_and_check
self.dataModel = DataFrameModel(data, parent=self)
File "/home/george/anaconda/lib/python2.7/site-packages/spyderlib/widgets/dataframeeditor.py", line 90, in __init__
self.max_min_col_update()
File "/home/george/anaconda/lib/python2.7/site-packages/spyderlib/widgets/dataframeeditor.py", line 124, in max_min_col_update
mask = float_intran &amp; (~ self.complex_intran)
File "/home/george/anaconda/lib/python2.7/site-packages/pandas/core/generic.py", line 639, in __invert__
arr = operator.inv(_values_from_object(self))
TypeError: ufunc 'invert' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
Traceback (most recent call last):
File "/home/george/anaconda/lib/python2.7/site-packages/spyderlib/widgets/dicteditor.py", line 503, in createEditor
if not editor.setup_and_check(value, title=key):
File "/home/george/anaconda/lib/python2.7/site-packages/spyderlib/widgets/dataframeeditor.py", line 494, in setup_and_check
self.dataModel = DataFrameModel(data, parent=self)
File "/home/george/anaconda/lib/python2.7/site-packages/spyderlib/widgets/dataframeeditor.py", line 90, in __init__
self.max_min_col_update()
File "/home/george/anaconda/lib/python2.7/site-packages/spyderlib/widgets/dataframeeditor.py", line 124, in max_min_col_update
mask = float_intran &amp; (~ self.complex_intran)
File "/home/george/anaconda/lib/python2.7/site-packages/pandas/core/generic.py", line 639, in __invert__
arr = operator.inv(_values_from_object(self))
TypeError: ufunc 'invert' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

# Fixed code
def max_min_col_update(self):
    """Determines the maximum and minimum number in each column"""
    # If there are no rows to compute max/min then return
    if self.df.shape[0] == 0:
        return
    max_r = self.df.max(numeric_only=True)
    min_r = self.df.min(numeric_only=True)
    self.max_min_col = list(zip(max_r, min_r))
    if len(self.max_min_col) != self.df.shape[1]:
        # Then it contain complex numbers or other types
        float_intran = self.df.applymap(lambda e: isinstance(e, _sup_nr))
        self.complex_intran = self.df.applymap(lambda e: isinstance(e, _sup_com))
        mask = float_intran & (~self.complex_intran)
        try:
            df_abs = self.df[self.complex_intran].abs()
        except TypeError:
            df_abs = self.df[self.complex_intran]
        max_c = df_abs.max(skipna=True)
        min_c = df_abs.min(skipna=True)
        df_real = self.df[mask]
        max_r = df_real.max(skipna=True)
        min_r = df_real.min(skipna=True)
        self.max_min_col = list(
            zip(
                DataFrame([max_c, max_r]).max(skipna=True),
                DataFrame([min_c, min_r]).min(skipna=True),
            )
        )
    self.max_min_col = [
        [vmax, vmin - 1] if vmax == vmin else [vmax, vmin]
        for vmax, vmin in self.max_min_col
    ]