Skip to content

Commit 153c75a

Browse files
committed
Update describe.py and format.py
1 parent 74cfc9c commit 153c75a

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

pandas/core/methods/describe.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ def _refine_percentiles(
352352
return np.array([0.25, 0.5, 0.75])
353353

354354
# Fix for issue #60550 :
355-
elif isinstance(percentiles, (list, np.ndarray, Series)) and len(percentiles) == 0:
355+
if isinstance(percentiles, (list, np.ndarray, Series)) and len(percentiles) == 0:
356356
return np.array([])
357357

358358
# explicit conversion of `percentiles` to list

pandas/io/formats/format.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -1577,8 +1577,12 @@ def format_percentiles(
15771577
raise ValueError("percentiles should all be in the interval [0,1]")
15781578

15791579
# Fix for issue #60550
1580-
percentiles = 100 * percentiles if percentiles else np.array([])
1580+
if len(percentiles) > 0 :
1581+
percentiles = 100 * percentiles
15811582

1583+
else :
1584+
percentiles = np.array([])
1585+
15821586
prec = get_precision(percentiles)
15831587
percentiles_round_type = percentiles.round(prec).astype(int)
15841588

@@ -1600,7 +1604,7 @@ def format_percentiles(
16001604
def get_precision(array: np.ndarray | Sequence[float]) -> int:
16011605
# Fix for issue #60550
16021606
if array.size == 0:
1603-
return 0
1607+
return 0
16041608

16051609
to_begin = array[0] if array[0] > 0 else None
16061610
to_end = 100 - array[-1] if array[-1] < 100 else None

0 commit comments

Comments
 (0)