Skip to content

Commit 6d9b476

Browse files
jbrockmendeltopper-123
authored andcommitted
CLN: remove is_stringlike (#29450)
1 parent e131b21 commit 6d9b476

File tree

6 files changed

+7
-35
lines changed

6 files changed

+7
-35
lines changed

pandas/core/dtypes/common.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
is_re_compilable,
4646
is_scalar,
4747
is_sequence,
48-
is_string_like,
4948
)
5049

5150
from pandas._typing import ArrayLike
@@ -1383,8 +1382,8 @@ def is_numeric_v_string_like(a, b):
13831382
is_a_string_array = is_a_array and is_string_like_dtype(a)
13841383
is_b_string_array = is_b_array and is_string_like_dtype(b)
13851384

1386-
is_a_scalar_string_like = not is_a_array and is_string_like(a)
1387-
is_b_scalar_string_like = not is_b_array and is_string_like(b)
1385+
is_a_scalar_string_like = not is_a_array and isinstance(a, str)
1386+
is_b_scalar_string_like = not is_b_array and isinstance(b, str)
13881387

13891388
return (
13901389
(is_a_numeric_array and is_b_scalar_string_like)

pandas/core/dtypes/inference.py

-24
Original file line numberDiff line numberDiff line change
@@ -67,30 +67,6 @@ def is_number(obj):
6767
return isinstance(obj, (Number, np.number))
6868

6969

70-
def is_string_like(obj):
71-
"""
72-
Check if the object is a string.
73-
74-
Parameters
75-
----------
76-
obj : The object to check
77-
78-
Examples
79-
--------
80-
>>> is_string_like("foo")
81-
True
82-
>>> is_string_like(1)
83-
False
84-
85-
Returns
86-
-------
87-
is_str_like : bool
88-
Whether `obj` is a string or not.
89-
"""
90-
91-
return isinstance(obj, str)
92-
93-
9470
def _iterable_not_string(obj):
9571
"""
9672
Check if the object is an iterable but not a string.

pandas/core/indexes/datetimes.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
is_integer,
1717
is_list_like,
1818
is_scalar,
19-
is_string_like,
2019
)
2120
from pandas.core.dtypes.concat import concat_compat
2221
from pandas.core.dtypes.dtypes import DatetimeTZDtype
@@ -1659,7 +1658,7 @@ def bdate_range(
16591658
msg = "freq must be specified for bdate_range; use date_range instead"
16601659
raise TypeError(msg)
16611660

1662-
if is_string_like(freq) and freq.startswith("C"):
1661+
if isinstance(freq, str) and freq.startswith("C"):
16631662
try:
16641663
weekmask = weekmask or "Mon Tue Wed Thu Fri"
16651664
freq = prefix_mapping[freq](holidays=holidays, weekmask=weekmask)

pandas/core/series.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
is_list_like,
3535
is_object_dtype,
3636
is_scalar,
37-
is_string_like,
3837
is_timedelta64_dtype,
3938
)
4039
from pandas.core.dtypes.generic import (
@@ -4539,7 +4538,7 @@ def to_csv(self, *args, **kwargs):
45394538
# passed as second argument (while the first is the same)
45404539
maybe_sep = args[1]
45414540

4542-
if not (is_string_like(maybe_sep) and len(maybe_sep) == 1):
4541+
if not (isinstance(maybe_sep, str) and len(maybe_sep) == 1):
45434542
# old signature
45444543
warnings.warn(
45454544
"The signature of `Series.to_csv` was aligned "

pandas/core/strings.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
is_list_like,
2020
is_re,
2121
is_scalar,
22-
is_string_like,
2322
)
2423
from pandas.core.dtypes.generic import (
2524
ABCDataFrame,
@@ -601,7 +600,7 @@ def str_replace(arr, pat, repl, n=-1, case=None, flags=0, regex=True):
601600
"""
602601

603602
# Check whether repl is valid (GH 13438, GH 15055)
604-
if not (is_string_like(repl) or callable(repl)):
603+
if not (isinstance(repl, str) or callable(repl)):
605604
raise TypeError("repl must be a string or callable")
606605

607606
is_compiled_re = is_re(pat)

pandas/io/formats/style.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from pandas.compat._optional import import_optional_dependency
1919
from pandas.util._decorators import Appender
2020

21-
from pandas.core.dtypes.common import is_float, is_string_like
21+
from pandas.core.dtypes.common import is_float
2222

2323
import pandas as pd
2424
from pandas.api.types import is_dict_like, is_list_like
@@ -1488,7 +1488,7 @@ def _get_level_lengths(index, hidden_elements=None):
14881488

14891489

14901490
def _maybe_wrap_formatter(formatter):
1491-
if is_string_like(formatter):
1491+
if isinstance(formatter, str):
14921492
return lambda x: formatter.format(x)
14931493
elif callable(formatter):
14941494
return formatter

0 commit comments

Comments
 (0)