Skip to content

Commit f0c2097

Browse files
committed
Move logic outside
1 parent f55ca62 commit f0c2097

File tree

3 files changed

+5
-8
lines changed

3 files changed

+5
-8
lines changed

pandas/core/arrays/arrow/array.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2581,7 +2581,7 @@ def _str_split(
25812581
n = None
25822582
if pat is None:
25832583
split_func = pc.utf8_split_whitespace
2584-
elif regex or (regex is None and len(pat) != 1):
2584+
elif regex:
25852585
split_func = functools.partial(pc.split_pattern_regex, pattern=pat)
25862586
else:
25872587
split_func = functools.partial(pc.split_pattern, pattern=pat)

pandas/core/strings/accessor.py

+3
Original file line numberDiff line numberDiff line change
@@ -910,6 +910,9 @@ def split(
910910
)
911911
if is_re(pat):
912912
regex = True
913+
elif pat is not None and regex is None:
914+
# regex is None so link to old behavior #43563
915+
regex = len(pat) != 1
913916
result = self._data.array._str_split(pat, n, expand, regex)
914917
if self._data.dtype == "category":
915918
dtype = self._data.dtype.categories.dtype

pandas/core/strings/object_array.py

+1-7
Original file line numberDiff line numberDiff line change
@@ -339,14 +339,8 @@ def _str_split(
339339
new_pat: str | re.Pattern
340340
if regex is True or isinstance(pat, re.Pattern):
341341
new_pat = re.compile(pat)
342-
elif regex is False:
343-
new_pat = pat
344-
# regex is None so link to old behavior #43563
345342
else:
346-
if len(pat) == 1:
347-
new_pat = pat
348-
else:
349-
new_pat = re.compile(pat)
343+
new_pat = pat
350344

351345
if isinstance(new_pat, re.Pattern):
352346
if n is None or n == -1:

0 commit comments

Comments
 (0)