Skip to content

Commit a315ef0

Browse files
committed
BUG-23282 Move check to _wrap_result and add bug number to tests
1 parent 8caeaed commit a315ef0

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

pandas/core/nanops.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,9 @@ def _view_if_needed(values):
269269
def _wrap_results(result, dtype):
270270
""" wrap our results if needed """
271271

272+
if (is_integer(result) and is_datetime_or_timedelta_dtype(dtype)
273+
and result == _int64_max):
274+
result = tslibs.iNaT
272275
if is_datetime64_dtype(dtype):
273276
if not isinstance(result, np.ndarray):
274277
result = tslibs.Timestamp(result)
@@ -718,9 +721,6 @@ def reduction(values, axis=None, skipna=True, mask=None):
718721
result = np.nan
719722
else:
720723
result = getattr(values, meth)(axis)
721-
if (is_integer(result) and is_datetime_or_timedelta_dtype(dtype)
722-
and result == _int64_max):
723-
result = tslibs.iNaT
724724

725725
result = _wrap_results(result, dtype)
726726
return _maybe_null_out(result, axis, mask)

pandas/tests/series/test_datetime_values.py

+2
Original file line numberDiff line numberDiff line change
@@ -515,10 +515,12 @@ def test_dt_timetz_accessor(self, tz_naive_fixture):
515515
pd.Series([pd.NaT, pd.Timedelta('nat')]),
516516
pd.Series([pd.Timedelta('nat'), pd.Timedelta('nat')])])
517517
def test_minmax_nat_series(self, nat):
518+
# GH 23282
518519
assert nat.min() is pd.NaT
519520
assert nat.max() is pd.NaT
520521

521522
@pytest.mark.parametrize('nat', [
523+
# GH 23282
522524
pd.DataFrame([pd.NaT, pd.NaT]),
523525
pd.DataFrame([pd.NaT, pd.Timedelta('nat')]),
524526
pd.DataFrame([pd.Timedelta('nat'), pd.Timedelta('nat')])])

0 commit comments

Comments
 (0)