# Buggy code
def mean(self, axis, **kwargs):
    if kwargs.get("level") is not None:
        return self.default_to_pandas(pandas.DataFrame.mean, axis=axis, **kwargs)

    skipna = kwargs.get("skipna", True)

    def map_apply_fn(ser, **kwargs):
        try:
            sum_result = ser.sum(skipna=skipna)
            count_result = ser.count()
        except TypeError:
            return None
        else:
            return (sum_result, count_result)

    def reduce_apply_fn(ser, **kwargs):
        sum_result = ser.apply(lambda x: x[0]).sum(skipna=skipna)
        count_result = ser.apply(lambda x: x[1]).sum(skipna=skipna)
        return sum_result / count_result

    def reduce_fn(df, **kwargs):
        df.dropna(axis=1, inplace=True, how="any")
        return build_applyier(reduce_apply_fn, axis=axis)(df)

    def build_applyier(func, **applyier_kwargs):
        def applyier(df, **kwargs):
            result = df.apply(func, **applyier_kwargs)
            return result.set_axis(df.axes[axis ^ 1], axis=0)

        return applyier

    return MapReduceFunction.register(
        build_applyier(map_apply_fn, axis=axis, result_type="reduce"),
        reduce_fn,
        preserve_index=(kwargs.get("numeric_only") is not None),
    )(self, axis=axis, **kwargs)


# Traceback (AssertionError)
Traceback (most recent call last):
File "../TESTS/t2.py", line 108, in <module>
df_equals(md_df.mean(axis=1), pd_df.mean(axis=1))
File "/localdisk/dchigare/repos/modin_bp/modin/pandas/test/utils.py", line 520, in df_equals
assert_series_equal(df1, df2, check_dtype=False, check_series_type=False)
File "/localdisk/dchigare/miniconda3/envs/modin_tests/lib/python3.7/site-packages/pandas/_testing.py", line 1401, in assert_series_equal
index_values=np.asarray(left.index),
File "pandas/_libs/testing.pyx", line 67, in pandas._libs.testing.assert_almost_equal
File "pandas/_libs/testing.pyx", line 182, in pandas._libs.testing.assert_almost_equal
File "/localdisk/dchigare/miniconda3/envs/modin_tests/lib/python3.7/site-packages/pandas/_testing.py", line 1036, in raise_assert_detail
raise AssertionError(msg)
AssertionError: Series are different

Series values are different (100.0 %)
[index]: [0, 1, 2, 3]
[left]:  [nan, nan, nan, nan]
[right]: [-2.5, -2.1333333333333333, 6.033333333333334, 8.0]

# Fixed code
def mean(self, axis, **kwargs):
    if kwargs.get("level") is not None:
        return self.default_to_pandas(pandas.DataFrame.mean, axis=axis, **kwargs)

    skipna = kwargs.get("skipna", True)

    # TODO-FIX: this function may work incorrectly with user-defined "numeric" values.
    # Since `count(numeric_only=True)` discards all unknown "numeric" types, we can get incorrect
    # divisor inside the reduce function.
    def map_fn(df, **kwargs):
        result = pandas.DataFrame(
            {
                "sum": df.sum(axis=axis, skipna=skipna),
                "count": df.count(axis=axis, numeric_only=True),
            }
        )
        return result if axis else result.T

    def reduce_fn(df, **kwargs):
        sum_cols = df["sum"] if axis else df.loc["sum"]
        count_cols = df["count"] if axis else df.loc["count"]

        if not isinstance(sum_cols, pandas.Series):
            # If we got `NaN` as the result of the sum in any axis partition,
            # then we must consider the whole sum as `NaN`, so setting `skipna=False`
            sum_cols = sum_cols.sum(axis=axis, skipna=False)
            count_cols = count_cols.sum(axis=axis, skipna=False)
        return sum_cols / count_cols

    return MapReduceFunction.register(
        map_fn,
        reduce_fn,
        preserve_index=(kwargs.get("numeric_only") is not None),
    )(self, axis=axis, **kwargs)