Skip to content

Commit

Permalink
BUG-23282 Add additional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinZhengBC committed Oct 23, 2018
1 parent ef91c24 commit 8caeaed
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
3 changes: 2 additions & 1 deletion pandas/core/nanops.py
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,8 @@ def reduction(values, axis=None, skipna=True, mask=None):
result = np.nan
else:
result = getattr(values, meth)(axis)
if is_integer(result) and result == _int64_max:
if (is_integer(result) and is_datetime_or_timedelta_dtype(dtype)
and result == _int64_max):
result = tslibs.iNaT

result = _wrap_results(result, dtype)
Expand Down
19 changes: 15 additions & 4 deletions pandas/tests/series/test_datetime_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,18 @@ def test_dt_timetz_accessor(self, tz_naive_fixture):
result = s.dt.timetz
tm.assert_series_equal(result, expected)

def test_minmax_nat(self):
series = pd.Series([pd.NaT, pd.NaT])
assert series.min() is pd.NaT
assert series.max() is pd.NaT
@pytest.mark.parametrize('nat', [
pd.Series([pd.NaT, pd.NaT]),
pd.Series([pd.NaT, pd.Timedelta('nat')]),
pd.Series([pd.Timedelta('nat'), pd.Timedelta('nat')])])
def test_minmax_nat_series(self, nat):
assert nat.min() is pd.NaT
assert nat.max() is pd.NaT

@pytest.mark.parametrize('nat', [
pd.DataFrame([pd.NaT, pd.NaT]),
pd.DataFrame([pd.NaT, pd.Timedelta('nat')]),
pd.DataFrame([pd.Timedelta('nat'), pd.Timedelta('nat')])])
def test_minmax_nat_dataframe(self, nat):
assert nat.min()[0] is pd.NaT
assert nat.max()[0] is pd.NaT

0 comments on commit 8caeaed

Please sign in to comment.