# Buggy code
def tile(cls, op: "DataFrameCartesianChunk"):
    left = op.left
    right = op.right
    out = op.outputs[0]

    if left.ndim == 2 and left.chunk_shape[1] > 1:
        check_chunks_unknown_shape([left], TilesError)
        # if left is a DataFrame, make sure 1 chunk on axis columns
        left = left.rechunk({1: left.shape[1]})._inplace_tile()
    if right.ndim == 2 and right.chunk_shape[1] > 1:
        check_chunks_unknown_shape([right], TilesError)
        # if right is a DataFrame, make sure 1 chunk on axis columns
        right = right.rechunk({1: right.shape[1]})._inplace_tile()

    out_chunks = []
    nsplits = [[]] if out.ndim == 1 else [[], [out.shape[1]]]
    i = 0
    for left_chunk in left.chunks:
        for right_chunk in right.chunks:
            chunk_op = op.copy().reset_key()
            chunk_op._tileable_op_key = op.key
            if op.output_types[0] == OutputType.dataframe:
                shape = (np.nan, out.shape[1])
                index_value = parse_index(
                    out.index_value.to_pandas(),
                    left_chunk,
                    right_chunk,
                    op.func,
                    op.args,
                    op.kwargs,
                )
                out_chunk = chunk_op.new_chunk(
                    [left_chunk, right_chunk],
                    shape=shape,
                    index_value=index_value,
                    columns_value=out.columns_value,
                    index=(i, 0),
                )
                out_chunks.append(out_chunk)
                nsplits[0].append(out_chunk.shape[0])
            else:
                shape = (np.nan,)
                index_value = parse_index(
                    out.index_value.to_pandas(),
                    left_chunk,
                    right_chunk,
                    op.func,
                    op.args,
                    op.kwargs,
                )
                out_chunk = chunk_op.new_chunk(
                    [left_chunk, right_chunk],
                    shape=shape,
                    index_value=index_value,
                    name=out.name,
                    index=(i,),
                )
                out_chunks.append(out_chunk)
                nsplits[0].append(out_chunk.shape[0])
            i += 1

    params = out.params
    params["nsplits"] = tuple(tuple(ns) for ns in nsplits)
    params["chunks"] = out_chunks
    new_op = op.copy()
    return new_op.new_tileables(op.inputs, kws=[params])


# Traceback (ValueError)
Traceback (most recent call last):
File "/home/smartguo/lib/anaconda3/envs/mars/lib/python3.7/site-packages/pandas/core/dtypes/common.py", line 171, in ensure_python_int
new_value = int(value)
ValueError: cannot convert float NaN to integer

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "tensor_loop.py", line 14, in <module>
df_res = md.DataFrame(score, columns=["probability"])
File "/home/smartguo/lib/anaconda3/envs/mars/lib/python3.7/site-packages/mars/dataframe/initializer.py", line 47, in __init__
df = dataframe_from_tensor(data, index=index, columns=columns, gpu=gpu, sparse=sparse)
File "/home/smartguo/lib/anaconda3/envs/mars/lib/python3.7/site-packages/mars/dataframe/datasource/from_tensor.py", line 357, in dataframe_from_tensor
return op(tensor, index, columns)
File "/home/smartguo/lib/anaconda3/envs/mars/lib/python3.7/site-packages/mars/utils.py", line 451, in _inner
return func(*args, **kwargs)
File "/home/smartguo/lib/anaconda3/envs/mars/lib/python3.7/site-packages/mars/dataframe/datasource/from_tensor.py", line 83, in __call__
return self._call_input_tensor(input_tensor, index, columns)
File "/home/smartguo/lib/anaconda3/envs/mars/lib/python3.7/site-packages/mars/dataframe/datasource/from_tensor.py", line 156, in _call_input_tensor
index_value = parse_index(pd.RangeIndex(start=0, stop=input_tensor.shape[0]))
File "/home/smartguo/lib/anaconda3/envs/mars/lib/python3.7/site-packages/pandas/core/indexes/range.py", line 107, in __new__
stop = ensure_python_int(stop)
File "/home/smartguo/lib/anaconda3/envs/mars/lib/python3.7/site-packages/pandas/core/dtypes/common.py", line 174, in ensure_python_int
raise TypeError(f"Wrong type {type(value)} for value {value}") from err
TypeError: Wrong type <class 'float'> for value nan

# Fixed code
def tile(cls, op: "DataFrameCartesianChunk"):
    left = op.left
    right = op.right
    out = op.outputs[0]

    if left.ndim == 2 and left.chunk_shape[1] > 1:
        check_chunks_unknown_shape([left], TilesError)
        # if left is a DataFrame, make sure 1 chunk on axis columns
        left = left.rechunk({1: left.shape[1]})._inplace_tile()
    if right.ndim == 2 and right.chunk_shape[1] > 1:
        check_chunks_unknown_shape([right], TilesError)
        # if right is a DataFrame, make sure 1 chunk on axis columns
        right = right.rechunk({1: right.shape[1]})._inplace_tile()

    out_chunks = []
    nsplits = [[]] if out.ndim == 1 else [[], [out.shape[1]]]
    i = 0
    for left_chunk in left.chunks:
        for right_chunk in right.chunks:
            chunk_op = op.copy().reset_key()
            chunk_op._tileable_op_key = op.key
            if op.output_types[0] == OutputType.dataframe:
                shape = (np.nan, out.shape[1])
                index_value = parse_index(
                    out.index_value.to_pandas(),
                    left_chunk,
                    right_chunk,
                    op.func,
                    op.args,
                    op.kwargs,
                )
                out_chunk = chunk_op.new_chunk(
                    [left_chunk, right_chunk],
                    shape=shape,
                    index_value=index_value,
                    columns_value=out.columns_value,
                    dtypes=out.dtypes,
                    index=(i, 0),
                )
                out_chunks.append(out_chunk)
                nsplits[0].append(out_chunk.shape[0])
            else:
                shape = (np.nan,)
                index_value = parse_index(
                    out.index_value.to_pandas(),
                    left_chunk,
                    right_chunk,
                    op.func,
                    op.args,
                    op.kwargs,
                )
                out_chunk = chunk_op.new_chunk(
                    [left_chunk, right_chunk],
                    shape=shape,
                    index_value=index_value,
                    dtype=out.dtype,
                    name=out.name,
                    index=(i,),
                )
                out_chunks.append(out_chunk)
                nsplits[0].append(out_chunk.shape[0])
            i += 1

    params = out.params
    params["nsplits"] = tuple(tuple(ns) for ns in nsplits)
    params["chunks"] = out_chunks
    new_op = op.copy()
    return new_op.new_tileables(op.inputs, kws=[params])