@@ -422,8 +422,8 @@ def test_describe_empty_percentiles(self):
422
422
# Case 1: Passing an empty list
423
423
result = df .describe (percentiles = [])
424
424
expected = DataFrame (
425
- {"a" : [5 , 3 , 1 , 5 ]},
426
- index = ["count" , "mean" , " min" , "max" ],
425
+ {"a" : [5 ,3 , 1.581139 , 1 , 5 ]},
426
+ index = ["count" ,"mean" ,"std" , " min" ,"max" ],
427
427
)
428
428
tm .assert_frame_equal (result , expected )
429
429
@@ -438,7 +438,37 @@ def test_describe_with_single_percentile(self):
438
438
# Case 1: Passing a single percentile
439
439
result = df .describe (percentiles = [0.5 ])
440
440
expected = DataFrame (
441
- {"a" : [5 , 3 , 1 , 3.0 ]},
442
- index = ["count" , "mean" , " min" , "50%" ],
441
+ {"a" : [5 , 3 , 1.581139 , 1 , 3 , 5 ]},
442
+ index = ["count" ,"mean" ,"std" , " min" ,"50%" , "max " ],
443
443
)
444
444
tm .assert_frame_equal (result , expected )
445
+
446
+
447
+ def test_describe_empty_numpy_percentile (self ):
448
+ df = DataFrame ({"a" : [1 , 2 , 3 , 4 , 5 ]})
449
+
450
+ # Passing empty NumPy array as percentiles
451
+ result = df .describe (percentiles = np .array ([]))
452
+
453
+ # Expected output should only include count, mean, std, min, and max (no percentiles)
454
+ expected = DataFrame (
455
+ {"a" : [5 , 3.0 , 1.581139 , 1 , 5 ]},
456
+ index = ["count" , "mean" , "std" , "min" , "max" ]
457
+ )
458
+ tm .assert_frame_equal (result , expected )
459
+
460
+
461
+
462
+ def test_describe_empty_series_percentile (self ):
463
+ df = DataFrame ({"a" : [1 , 2 , 3 , 4 , 5 ]})
464
+
465
+ # Passing empty Series as percentiles
466
+ result = df .describe (percentiles = pd .Series ([], dtype = float ))
467
+
468
+ # Expected output should only include count, mean, std, min, and max (no percentiles)
469
+ expected = DataFrame (
470
+ {"a" : [5 , 3.0 , 1.581139 , 1 , 5 ]},
471
+ index = ["count" , "mean" , "std" , "min" , "max" ]
472
+ )
473
+
474
+ tm .assert_frame_equal (result , expected )
0 commit comments