Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REF: isinstance(x, int) -> is_integer(x) #46119

Merged
merged 1 commit into from Feb 26, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 8 additions & 3 deletions pandas/io/formats/style_render.py
Expand Up @@ -25,6 +25,11 @@
from pandas._typing import Level
from pandas.compat._optional import import_optional_dependency

from pandas.core.dtypes.common import (
is_complex,
is_float,
is_integer,
)
from pandas.core.dtypes.generic import ABCSeries

from pandas import (
Expand Down Expand Up @@ -1442,9 +1447,9 @@ def _default_formatter(x: Any, precision: int, thousands: bool = False) -> Any:
value : Any
Matches input type, or string if input is float or complex or int with sep.
"""
if isinstance(x, (float, complex)):
if is_float(x) or is_complex(x):
return f"{x:,.{precision}f}" if thousands else f"{x:.{precision}f}"
elif isinstance(x, int):
elif is_integer(x):
return f"{x:,.0f}" if thousands else f"{x:.0f}"
return x

Expand All @@ -1459,7 +1464,7 @@ def _wrap_decimal_thousands(
"""

def wrapper(x):
if isinstance(x, (float, complex, int)):
if is_float(x) or is_integer(x) or is_complex(x):
if decimal != "." and thousands is not None and thousands != ",":
return (
formatter(x)
Expand Down