Skip to content

Commit

Permalink
Fixed mean (#129)
Browse files Browse the repository at this point in the history
* Fixed mean with numeric_only=False

* Fixed mean returning the wrong value

* resolve comments
  • Loading branch information
williamma12 authored and devin-petersohn committed Oct 8, 2018
1 parent ab2ccef commit 1c01b0a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions modin/data_management/data_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -929,8 +929,8 @@ def mean(self, **kwargs):
"""
# Pandas default is 0 (though not mentioned in docs)
axis = kwargs.get("axis", 0)
func = self._prepare_method(pandas.DataFrame.mean, **kwargs)
return self.full_reduce(axis, func, numeric_only=True)
kwargs["numeric_only"] = True
return self.sum(**kwargs).divide(self.count(axis=axis, numeric_only=True))

def min(self, **kwargs):
"""Returns the minimum from each column or row.
Expand Down
2 changes: 2 additions & 0 deletions modin/pandas/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -2168,6 +2168,8 @@ def mean(self, axis=None, skipna=None, level=None, numeric_only=None, **kwargs):
The mean of the DataFrame. (Pandas series)
"""
axis = pandas.DataFrame()._get_axis_number(axis) if axis is not None else 0
if numeric_only is not None and not numeric_only:
self._validate_dtypes(numeric_only=True)
return self._data_manager.mean(
axis=axis, skipna=skipna, level=level, numeric_only=numeric_only, **kwargs
)
Expand Down

0 comments on commit 1c01b0a

Please sign in to comment.