# Buggy code
def _call_input_tensor(self, input_tensor, index, columns):
    if input_tensor.ndim not in {1, 2}:
        raise ValueError("Must pass 1-d or 2-d input")
    inputs = [input_tensor]

    if index is not None:
        if input_tensor.shape[0] != len(index):
            raise ValueError(
                f"index {index} should have the same shape with tensor: {input_tensor.shape[0]}"
            )
        index_value = self._process_index(index, inputs)
    elif isinstance(input_tensor, SERIES_TYPE):
        index_value = input_tensor.index_value
    else:
        index_value = parse_index(pd.RangeIndex(start=0, stop=input_tensor.shape[0]))

    if columns is not None:
        if not (
            input_tensor.ndim == 1
            and len(columns) == 1
            or input_tensor.shape[1] == len(columns)
        ):
            raise ValueError(
                f"columns {columns} should have the same shape with tensor: {input_tensor.shape[1]}"
            )
        if not isinstance(columns, pd.Index):
            if isinstance(columns, Base):
                raise NotImplementedError("The columns value cannot be a tileable")
            columns = pd.Index(columns)
        columns_value = parse_index(columns, store_data=True)
    else:
        if input_tensor.ndim == 1:
            # convert to 1-d DataFrame
            columns_value = parse_index(pd.RangeIndex(start=0, stop=1), store_data=True)
        else:
            columns_value = parse_index(
                pd.RangeIndex(start=0, stop=input_tensor.shape[1]), store_data=True
            )

    if input_tensor.ndim == 1:
        shape = (input_tensor.shape[0], 1)
    else:
        shape = input_tensor.shape

    return self.new_dataframe(
        inputs,
        shape,
        dtypes=self.dtypes,
        index_value=index_value,
        columns_value=columns_value,
    )


# 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 _call_input_tensor(self, input_tensor, index, columns):
    if input_tensor.ndim not in {1, 2}:
        raise ValueError("Must pass 1-d or 2-d input")
    inputs = [input_tensor]

    if index is not None:
        if input_tensor.shape[0] != len(index):
            raise ValueError(
                f"index {index} should have the same shape with tensor: {input_tensor.shape[0]}"
            )
        index_value = self._process_index(index, inputs)
    elif isinstance(input_tensor, SERIES_TYPE):
        index_value = input_tensor.index_value
    else:
        stop = input_tensor.shape[0]
        stop = -1 if np.isnan(stop) else stop
        index_value = parse_index(pd.RangeIndex(start=0, stop=stop))

    if columns is not None:
        if not (
            input_tensor.ndim == 1
            and len(columns) == 1
            or input_tensor.shape[1] == len(columns)
        ):
            raise ValueError(
                f"columns {columns} should have the same shape with tensor: {input_tensor.shape[1]}"
            )
        if not isinstance(columns, pd.Index):
            if isinstance(columns, Base):
                raise NotImplementedError("The columns value cannot be a tileable")
            columns = pd.Index(columns)
        columns_value = parse_index(columns, store_data=True)
    else:
        if input_tensor.ndim == 1:
            # convert to 1-d DataFrame
            columns_value = parse_index(pd.RangeIndex(start=0, stop=1), store_data=True)
        else:
            columns_value = parse_index(
                pd.RangeIndex(start=0, stop=input_tensor.shape[1]), store_data=True
            )

    if input_tensor.ndim == 1:
        shape = (input_tensor.shape[0], 1)
    else:
        shape = input_tensor.shape

    return self.new_dataframe(
        inputs,
        shape,
        dtypes=self.dtypes,
        index_value=index_value,
        columns_value=columns_value,
    )