# Buggy code
def rechunk(
    a, chunk_size, threshold=None, chunk_size_limit=None, reassign_worker=False
):
    if not any(pd.isna(s) for s in a.shape):
        # do client check only when no unknown shape,
        # real nsplits will be recalculated inside `tile`
        chunk_size = _get_chunk_size(a, chunk_size)
        if chunk_size == a.nsplits:
            return a

    op = DataFrameRechunk(
        chunk_size=chunk_size,
        threshold=threshold,
        chunk_size_limit=chunk_size_limit,
        reassign_worker=reassign_worker,
    )
    return op(a)


# 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 rechunk(
    a, chunk_size, threshold=None, chunk_size_limit=None, reassign_worker=False
):
    if not any(pd.isna(s) for s in a.shape) and not a.is_coarse():
        # do client check only when no unknown shape,
        # real nsplits will be recalculated inside `tile`
        chunk_size = _get_chunk_size(a, chunk_size)
        if chunk_size == a.nsplits:
            return a

    op = DataFrameRechunk(
        chunk_size=chunk_size,
        threshold=threshold,
        chunk_size_limit=chunk_size_limit,
        reassign_worker=reassign_worker,
    )
    return op(a)