MCPcopy
hub / github.com/pandas-dev/pandas / _str_split

Method _str_split

pandas/core/strings/object_array.py:358–389  ·  view source on GitHub ↗
(
        self,
        pat: str | re.Pattern | None = None,
        n=-1,
        expand: bool = False,
        regex: bool | None = None,
    )

Source from the content-addressed store, hash-verified

356 return self._str_map(f)
357
358 def _str_split(
359 self,
360 pat: str | re.Pattern | None = None,
361 n=-1,
362 expand: bool = False,
363 regex: bool | None = None,
364 ):
365 if pat is None:
366 if n is None or n == 0:
367 n = -1
368 f = lambda x: x.split(pat, n)
369 else:
370 new_pat: str | re.Pattern
371 if regex is True or isinstance(pat, re.Pattern):
372 new_pat = re.compile(pat)
373 elif regex is False:
374 new_pat = pat
375 # regex is None so link to old behavior #43563
376 elif len(pat) == 1:
377 new_pat = pat
378 else:
379 new_pat = re.compile(pat)
380
381 if isinstance(new_pat, re.Pattern):
382 if n is None or n == -1:
383 n = 0
384 f = lambda x: new_pat.split(x, maxsplit=n)
385 else:
386 if n is None or n == 0:
387 n = -1
388 f = lambda x: x.split(pat, n)
389 return self._str_map(f, dtype=object)
390
391 def _str_rsplit(self, pat=None, n=-1):
392 if n is None or n == 0:

Callers 1

splitMethod · 0.45

Calls 2

_str_mapMethod · 0.95
splitMethod · 0.80

Tested by

no test coverage detected