Skip to content

Commit dd005ab

Browse files
committed
Update test_describe.py
1 parent 153c75a commit dd005ab

File tree

1 file changed

+34
-4
lines changed

1 file changed

+34
-4
lines changed

pandas/tests/frame/methods/test_describe.py

+34-4
Original file line numberDiff line numberDiff line change
@@ -422,8 +422,8 @@ def test_describe_empty_percentiles(self):
422422
# Case 1: Passing an empty list
423423
result = df.describe(percentiles=[])
424424
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"],
427427
)
428428
tm.assert_frame_equal(result, expected)
429429

@@ -438,7 +438,37 @@ def test_describe_with_single_percentile(self):
438438
# Case 1: Passing a single percentile
439439
result = df.describe(percentiles=[0.5])
440440
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"],
443443
)
444444
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

Comments
 (0)