Skip to content

Commit ccdb97e

Browse files
meeseeksmachineattack68simonjayhawkins
authored
Backport PR #46119: REF: isinstance(x, int) -> is_integer(x) (#46501)
Co-authored-by: JHM Darbyshire <[email protected]> Co-authored-by: Simon Hawkins <[email protected]>
1 parent 1afa4d5 commit ccdb97e

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

pandas/io/formats/style_render.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@
2525
from pandas._typing import Level
2626
from pandas.compat._optional import import_optional_dependency
2727

28+
from pandas.core.dtypes.common import (
29+
is_complex,
30+
is_float,
31+
is_integer,
32+
)
2833
from pandas.core.dtypes.generic import ABCSeries
2934

3035
from pandas import (
@@ -1431,9 +1436,9 @@ def _default_formatter(x: Any, precision: int, thousands: bool = False) -> Any:
14311436
value : Any
14321437
Matches input type, or string if input is float or complex or int with sep.
14331438
"""
1434-
if isinstance(x, (float, complex)):
1439+
if is_float(x) or is_complex(x):
14351440
return f"{x:,.{precision}f}" if thousands else f"{x:.{precision}f}"
1436-
elif isinstance(x, int):
1441+
elif is_integer(x):
14371442
return f"{x:,.0f}" if thousands else f"{x:.0f}"
14381443
return x
14391444

@@ -1448,7 +1453,7 @@ def _wrap_decimal_thousands(
14481453
"""
14491454

14501455
def wrapper(x):
1451-
if isinstance(x, (float, complex, int)):
1456+
if is_float(x) or is_integer(x) or is_complex(x):
14521457
if decimal != "." and thousands is not None and thousands != ",":
14531458
return (
14541459
formatter(x)

0 commit comments

Comments
 (0)