Skip to content

Commit 57c041d

Browse files
attack68yehoshuadimarsky
authored andcommitted
is type refactor (pandas-dev#46119)
1 parent bd1de14 commit 57c041d

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 (
@@ -1442,9 +1447,9 @@ def _default_formatter(x: Any, precision: int, thousands: bool = False) -> Any:
14421447
value : Any
14431448
Matches input type, or string if input is float or complex or int with sep.
14441449
"""
1445-
if isinstance(x, (float, complex)):
1450+
if is_float(x) or is_complex(x):
14461451
return f"{x:,.{precision}f}" if thousands else f"{x:.{precision}f}"
1447-
elif isinstance(x, int):
1452+
elif is_integer(x):
14481453
return f"{x:,.0f}" if thousands else f"{x:.0f}"
14491454
return x
14501455

@@ -1459,7 +1464,7 @@ def _wrap_decimal_thousands(
14591464
"""
14601465

14611466
def wrapper(x):
1462-
if isinstance(x, (float, complex, int)):
1467+
if is_float(x) or is_integer(x) or is_complex(x):
14631468
if decimal != "." and thousands is not None and thousands != ",":
14641469
return (
14651470
formatter(x)

0 commit comments

Comments
 (0)