Skip to content

Commit

Permalink
Disable M8 in nanops
Browse files Browse the repository at this point in the history
  • Loading branch information
TomAugspurger committed Jan 24, 2019
1 parent 0c319f5 commit 4c6311c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions pandas/core/nanops.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@ def nansum(values, axis=None, skipna=True, min_count=0, mask=None):
return _wrap_results(the_sum, dtype)


@disallow('M8')
@bottleneck_switch()
def nanmean(values, axis=None, skipna=True, mask=None):
"""
Expand Down
16 changes: 16 additions & 0 deletions pandas/tests/frame/test_analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,22 @@ def test_mean(self, float_frame_with_na, float_frame, float_string_frame):
check_dates=True)
assert_stat_op_api('mean', float_frame, float_string_frame)

def test_mean_mixed_datetime_numeric(self):
# https://github.com/pandas-dev/pandas/issues/24752
df = pd.DataFrame({"A": [1, 1], "B": [pd.Timestamp('2000')] * 2})
result = df.mean()
expected = pd.Series([1.0], index=['A'])
tm.assert_series_equal(result, expected)

def test_mean_excludeds_datetimes(self):
# https://github.com/pandas-dev/pandas/issues/24752
# Our long-term desired behavior is unclear, but the behavior in
# 0.24.0rc1 was buggy.
df = pd.DataFrame({"A": [pd.Timestamp('2000')] * 2})
result = df.mean()
expected = pd.Series()
tm.assert_series_equal(result, expected)

def test_product(self, float_frame_with_na, float_frame,
float_string_frame):
assert_stat_op_calc('product', np.prod, float_frame_with_na)
Expand Down
3 changes: 3 additions & 0 deletions pandas/tests/test_nanops.py
Original file line number Diff line number Diff line change
Expand Up @@ -971,6 +971,9 @@ def prng(self):

class TestDatetime64NaNOps(object):
@pytest.mark.parametrize('tz', [None, 'UTC'])
@pytest.mark.xfail(reason="disabled")
# Enabling mean changes the behavior of DataFrame.mean
# See https://github.com/pandas-dev/pandas/issues/24752
def test_nanmean(self, tz):
dti = pd.date_range('2016-01-01', periods=3, tz=tz)
expected = dti[1]
Expand Down

0 comments on commit 4c6311c

Please sign in to comment.