# Buggy code
def merge_index_value(to_merge_index_values, store_data=False):
    """
    Merge index value according to their chunk index.
    :param to_merge_index_values: Dict object. {index: index_value}
    :return: Merged index_value
    """
    index_value = None
    min_val, min_val_close, max_val, max_val_close = None, None, None, None
    for _, chunk_index_value in sorted(to_merge_index_values.items()):
        if index_value is None:
            index_value = chunk_index_value.to_pandas()
            min_val, min_val_close, max_val, max_val_close = (
                chunk_index_value.min_val,
                chunk_index_value.min_val_close,
                chunk_index_value.max_val,
                chunk_index_value.max_val_close,
            )
        else:
            index_value = index_value.append(chunk_index_value.to_pandas())
            if chunk_index_value.min_val is not None:
                if min_val is None or min_val > chunk_index_value.min_val:
                    min_val = chunk_index_value.min_val
                    min_val_close = chunk_index_value.min_val_close
            if chunk_index_value.max_val is not None:
                if max_val is None or max_val < chunk_index_value.max_val:
                    max_val = chunk_index_value.max_val
                    max_val_close = chunk_index_value.max_val_close

    new_index_value = parse_index(index_value, store_data=store_data)
    if not new_index_value.has_value():
        new_index_value._index_value._min_val = min_val
        new_index_value._index_value._min_val_close = min_val_close
        new_index_value._index_value._max_val = max_val
        new_index_value._index_value._max_val_close = max_val_close
    return new_index_value


# Traceback (ValueError)
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/mars/scheduler/graph.py", line 411, in _execute_graph
self.prepare_graph(compose=compose)
File "/usr/local/lib/python3.6/dist-packages/mars/utils.py", line 383, in _wrapped
return func(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/mars/utils.py", line 457, in _inner
return func(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/mars/scheduler/graph.py", line 666, in prepare_graph
self._target_tileable_datas + fetch_tileables, tileable_graph)
File "/usr/local/lib/python3.6/dist-packages/mars/utils.py", line 457, in _inner
return func(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/mars/tiles.py", line 348, in build
tileables, tileable_graph=tileable_graph)
File "/usr/local/lib/python3.6/dist-packages/mars/utils.py", line 457, in _inner
return func(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/mars/tiles.py", line 262, in build
self._on_tile_failure(tileable_data.op, exc_info)
File "/usr/local/lib/python3.6/dist-packages/mars/tiles.py", line 301, in inner
raise exc_info[1].with_traceback(exc_info[2]) from None
File "/usr/local/lib/python3.6/dist-packages/mars/tiles.py", line 242, in build
tiled = self._tile(tileable_data, tileable_graph)
File "/usr/local/lib/python3.6/dist-packages/mars/tiles.py", line 337, in _tile
return super()._tile(tileable_data, tileable_graph)
File "/usr/local/lib/python3.6/dist-packages/mars/tiles.py", line 203, in _tile
tds = on_tile(tileable_data.op.outputs, tds)
File "/usr/local/lib/python3.6/dist-packages/mars/scheduler/graph.py", line 648, in on_tile
return self.context.wraps(handler.dispatch)(first.op)
File "/usr/local/lib/python3.6/dist-packages/mars/context.py", line 72, in h
return func(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/mars/utils.py", line 457, in _inner
return func(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/mars/tiles.py", line 119, in dispatch
tiled = op_cls.tile(op)
File "/usr/local/lib/python3.6/dist-packages/mars/dataframe/window/rolling/aggregation.py", line 308, in tile
inp = cls._check_can_be_tiled(op, is_window_int)
File "/usr/local/lib/python3.6/dist-packages/mars/dataframe/window/rolling/aggregation.py", line 167, in _check_can_be_tiled
inp = inp.rechunk({1: inp.shape[1]})._inplace_tile()
File "/usr/local/lib/python3.6/dist-packages/mars/core.py", line 168, in _inplace_tile
return handler.inplace_tile(self)
File "/usr/local/lib/python3.6/dist-packages/mars/tiles.py", line 136, in inplace_tile
dispatched = self.dispatch(to_tile.op)
File "/usr/local/lib/python3.6/dist-packages/mars/utils.py", line 457, in _inner
return func(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/mars/tiles.py", line 119, in dispatch
tiled = op_cls.tile(op)
File "/usr/local/lib/python3.6/dist-packages/mars/dataframe/base/rechunk.py", line 82, in tile
out = compute_rechunk(out.inputs[0], c)
File "/usr/local/lib/python3.6/dist-packages/mars/dataframe/base/rechunk.py", line 176, in compute_rechunk
index_value, columns_value, dtypes = _concat_dataframe_meta(to_merge)
File "/usr/local/lib/python3.6/dist-packages/mars/dataframe/base/rechunk.py", line 112, in _concat_dataframe_meta
columns_value = merge_index_value(idx_to_columns_value, store_data=True)
File "/usr/local/lib/python3.6/dist-packages/mars/dataframe/utils.py", line 730, in merge_index_value
if min_val is None or min_val > chunk_index_value.min_val:
ValueError: invalid literal for int() with base 10: 'minus'

# Fixed code
def merge_index_value(to_merge_index_values, store_data=False):
    """
    Merge index value according to their chunk index.
    :param to_merge_index_values: Dict object. {index: index_value}
    :return: Merged index_value
    """
    index_value = None
    min_val, min_val_close, max_val, max_val_close = None, None, None, None
    for _, chunk_index_value in sorted(to_merge_index_values.items()):
        if index_value is None:
            index_value = chunk_index_value.to_pandas()
            min_val, min_val_close, max_val, max_val_close = (
                chunk_index_value.min_val,
                chunk_index_value.min_val_close,
                chunk_index_value.max_val,
                chunk_index_value.max_val_close,
            )
        else:
            index_value = index_value.append(chunk_index_value.to_pandas())
            if chunk_index_value.min_val is not None:
                try:
                    if min_val is None or min_val > chunk_index_value.min_val:
                        min_val = chunk_index_value.min_val
                        min_val_close = chunk_index_value.min_val_close
                except TypeError:
                    # min_value has different types that cannot compare
                    # just stop compare
                    continue
            if chunk_index_value.max_val is not None:
                if max_val is None or max_val < chunk_index_value.max_val:
                    max_val = chunk_index_value.max_val
                    max_val_close = chunk_index_value.max_val_close

    new_index_value = parse_index(index_value, store_data=store_data)
    if not new_index_value.has_value():
        new_index_value._index_value._min_val = min_val
        new_index_value._index_value._min_val_close = min_val_close
        new_index_value._index_value._max_val = max_val
        new_index_value._index_value._max_val_close = max_val_close
    return new_index_value