We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ef91c24 commit 8caeaedCopy full SHA for 8caeaed
pandas/core/nanops.py
@@ -718,7 +718,8 @@ def reduction(values, axis=None, skipna=True, mask=None):
718
result = np.nan
719
else:
720
result = getattr(values, meth)(axis)
721
- if is_integer(result) and result == _int64_max:
+ if (is_integer(result) and is_datetime_or_timedelta_dtype(dtype)
722
+ and result == _int64_max):
723
result = tslibs.iNaT
724
725
result = _wrap_results(result, dtype)
pandas/tests/series/test_datetime_values.py
@@ -510,7 +510,18 @@ def test_dt_timetz_accessor(self, tz_naive_fixture):
510
result = s.dt.timetz
511
tm.assert_series_equal(result, expected)
512
513
- def test_minmax_nat(self):
514
- series = pd.Series([pd.NaT, pd.NaT])
515
- assert series.min() is pd.NaT
516
- 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')])])
517
+ def test_minmax_nat_series(self, nat):
518
+ assert nat.min() is pd.NaT
519
+ assert nat.max() is pd.NaT
520
+
521
522
+ pd.DataFrame([pd.NaT, pd.NaT]),
523
+ pd.DataFrame([pd.NaT, pd.Timedelta('nat')]),
524
+ pd.DataFrame([pd.Timedelta('nat'), pd.Timedelta('nat')])])
525
+ def test_minmax_nat_dataframe(self, nat):
526
+ assert nat.min()[0] is pd.NaT
527
+ assert nat.max()[0] is pd.NaT
0 commit comments