Skip to content

Commit

Permalink
BUG-23282 Move check to _wrap_result and add bug number to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinZhengBC committed Oct 23, 2018
1 parent 8caeaed commit ce0a7ee
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pandas/core/nanops.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,9 @@ def _view_if_needed(values):
def _wrap_results(result, dtype):
""" wrap our results if needed """

if (is_integer(result) and is_datetime_or_timedelta_dtype(dtype)
and result == _int64_max):
result = tslibs.iNaT
if is_datetime64_dtype(dtype):
if not isinstance(result, np.ndarray):
result = tslibs.Timestamp(result)
Expand Down Expand Up @@ -718,9 +721,6 @@ def reduction(values, axis=None, skipna=True, mask=None):
result = np.nan
else:
result = getattr(values, meth)(axis)
if (is_integer(result) and is_datetime_or_timedelta_dtype(dtype)
and result == _int64_max):
result = tslibs.iNaT

result = _wrap_results(result, dtype)
return _maybe_null_out(result, axis, mask)
Expand Down
2 changes: 2 additions & 0 deletions pandas/tests/series/test_datetime_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,10 +515,12 @@ def test_dt_timetz_accessor(self, tz_naive_fixture):
pd.Series([pd.NaT, pd.Timedelta('nat')]),
pd.Series([pd.Timedelta('nat'), pd.Timedelta('nat')])])
def test_minmax_nat_series(self, nat):
# GH 23282
assert nat.min() is pd.NaT
assert nat.max() is pd.NaT

@pytest.mark.parametrize('nat', [
# GH 23282
pd.DataFrame([pd.NaT, pd.NaT]),
pd.DataFrame([pd.NaT, pd.Timedelta('nat')]),
pd.DataFrame([pd.Timedelta('nat'), pd.Timedelta('nat')])])
Expand Down

0 comments on commit ce0a7ee

Please sign in to comment.