@@ -1274,3 +1274,28 @@ def test_series_broadcasting(self):
1274
1274
df_nan .clip (lower = s , axis = 0 )
1275
1275
for op in ["lt" , "le" , "gt" , "ge" , "eq" , "ne" ]:
1276
1276
getattr (df , op )(s_nan , axis = 0 )
1277
+
1278
+
1279
+ class TestDataFrameReductions :
1280
+ def test_min_max_dt64_with_NaT (self ):
1281
+ # Both NaT and Timestamp are in DataFrame.
1282
+ df = pd .DataFrame ({"foo" : [pd .NaT , pd .NaT , pd .Timestamp ("2012-05-01" )]})
1283
+
1284
+ res = df .min ()
1285
+ exp = pd .Series ([pd .Timestamp ("2012-05-01" )], index = ["foo" ])
1286
+ tm .assert_series_equal (res , exp )
1287
+
1288
+ res = df .max ()
1289
+ exp = pd .Series ([pd .Timestamp ("2012-05-01" )], index = ["foo" ])
1290
+ tm .assert_series_equal (res , exp )
1291
+
1292
+ # GH12941, only NaTs are in DataFrame.
1293
+ df = pd .DataFrame ({"foo" : [pd .NaT , pd .NaT ]})
1294
+
1295
+ res = df .min ()
1296
+ exp = pd .Series ([pd .NaT ], index = ["foo" ])
1297
+ tm .assert_series_equal (res , exp )
1298
+
1299
+ res = df .max ()
1300
+ exp = pd .Series ([pd .NaT ], index = ["foo" ])
1301
+ tm .assert_series_equal (res , exp )
0 commit comments