# Buggy code
def build_df(df_obj, fill_value=1, size=1):
    empty_df = build_empty_df(df_obj.dtypes, index=df_obj.index_value.to_pandas()[:0])
    dtypes = empty_df.dtypes
    record = [_generate_value(dtype, fill_value) for dtype in dtypes]
    if isinstance(empty_df.index, pd.MultiIndex):
        index = tuple(
            _generate_value(level.dtype, fill_value) for level in empty_df.index.levels
        )
        empty_df = empty_df.reindex(
            index=pd.MultiIndex.from_tuples([index], names=empty_df.index.names)
        )
        empty_df.iloc[0] = record
    else:
        index = _generate_value(empty_df.index.dtype, fill_value)
        empty_df.loc[index] = record

    empty_df = pd.concat([empty_df] * size)
    # make sure dtypes correct for MultiIndex
    for i, dtype in enumerate(dtypes.tolist()):
        s = empty_df.iloc[:, i]
        if not pd.api.types.is_dtype_equal(s.dtype, dtype):
            empty_df.iloc[:, i] = s.astype(dtype)
    return empty_df


# Traceback (ValueError)
import numpy as np
import pandas as pd
import mars.dataframe as md
rs = np.random.RandomState(0)
raw_df = rs.rand(20, 10)
raw_df = pd.DataFrame(np.where(raw_df > 0.4, raw_df, np.nan), columns=list('ABCDEFGHIJ'))
df = md.DataFrame(raw_df, chunk_size=6)
raw_df2 = rs.rand(20, 10)
raw_df2 = pd.DataFrame(np.where(raw_df2 > 0.4, raw_df2, np.nan), columns=list('ABCDEFGHIJ'))
df2 = md.DataFrame(raw_df2, chunk_size=4)
sumv = (df ** 2).mul(df2, axis=1, fill_value=0).sum(axis=0).execute()
Traceback (most recent call last):
File "/Users/wenjun.swj/miniconda3/lib/python3.8/site-packages/IPython/core/interactiveshell.py", line 3417, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-16-f7addf55e6d4>", line 1, in <module>
sumv = (df ** 2).mul(df2, axis=1, fill_value=0).sum(axis=0).execute()
File "/Users/wenjun.swj/Code/mars/mars/dataframe/arithmetic/__init__.py", line 118, in call_df_fill
return func(df, other, axis=axis, level=level, fill_value=fill_value)
File "/Users/wenjun.swj/Code/mars/mars/dataframe/arithmetic/multiply.py", line 48, in mul
return op(df, other)
File "/Users/wenjun.swj/Code/mars/mars/dataframe/arithmetic/core.py", line 499, in __call__
return self._call(x1, x2)
File "/Users/wenjun.swj/Code/mars/mars/dataframe/arithmetic/core.py", line 479, in _call
kw = self._calc_properties(df1, df2, axis=self.axis)
File "/Users/wenjun.swj/Code/mars/mars/dataframe/arithmetic/core.py", line 326, in _calc_properties
dtypes = pd.Series([infer_dtype(dt1, dt2, cls._operator) for dt1, dt2
File "/Users/wenjun.swj/miniconda3/lib/python3.8/site-packages/pandas/core/series.py", line 313, in __init__
raise ValueError(
ValueError: Length of passed values is 10, index implies 11.

# Fixed code
def build_df(df_obj, fill_value=1, size=1):
    empty_df = build_empty_df(df_obj.dtypes, index=df_obj.index_value.to_pandas()[:0])
    dtypes = empty_df.dtypes
    record = [_generate_value(dtype, fill_value) for dtype in dtypes]
    if len(record) != 0:  # columns is empty in some cases
        if isinstance(empty_df.index, pd.MultiIndex):
            index = tuple(
                _generate_value(level.dtype, fill_value)
                for level in empty_df.index.levels
            )
            empty_df = empty_df.reindex(
                index=pd.MultiIndex.from_tuples([index], names=empty_df.index.names)
            )
            empty_df.iloc[0] = record
        else:
            index = _generate_value(empty_df.index.dtype, fill_value)
            empty_df.loc[index] = record

    empty_df = pd.concat([empty_df] * size)
    # make sure dtypes correct for MultiIndex
    for i, dtype in enumerate(dtypes.tolist()):
        s = empty_df.iloc[:, i]
        if not pd.api.types.is_dtype_equal(s.dtype, dtype):
            empty_df.iloc[:, i] = s.astype(dtype)
    return empty_df