File tree 2 files changed +16
-2
lines changed
2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -384,8 +384,7 @@ def _na_for_min_count(
384
384
else :
385
385
assert axis is not None # assertion to make mypy happy
386
386
result_shape = values .shape [:axis ] + values .shape [axis + 1 :]
387
- result = np .empty (result_shape , dtype = values .dtype )
388
- result .fill (fill_value )
387
+ result = np .full (result_shape , fill_value )
389
388
return result
390
389
391
390
Original file line number Diff line number Diff line change @@ -2471,3 +2471,18 @@ def test_dt64arr_addsub_object_dtype_2d():
2471
2471
assert result2 .shape == (4 , 1 )
2472
2472
assert result2 .freq is None
2473
2473
assert (result2 .asi8 == 0 ).all ()
2474
+
2475
+
2476
+ def test_sum_empty_df_series ():
2477
+ # Calling the following defined sum function returned an error for dataframes but
2478
+ # returned NaT for series. # Check that the API is consistent in this sense when
2479
+ # operating on empty Series/DataFrames. See GH:33704 for more information
2480
+ df = pd .DataFrame (dict (x = pd .to_datetime ([])))
2481
+ series = pd .Series (pd .to_datetime ([]))
2482
+ assert (df .min ().x is NaT ) == (series .min () is NaT )
2483
+ assert (df .max ().x is NaT ) == (series .max () is NaT )
2484
+
2485
+ df = pd .DataFrame (dict (x = [np .nan ]))
2486
+ series = pd .Series ([np .nan ])
2487
+ assert np .isnan (df .min ().x ) == np .isnan (series .min ())
2488
+ assert np .isnan (df .max ().x ) == np .isnan (series .max ())
You can’t perform that action at this time.
0 commit comments