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

Method split

pandas/core/strings/accessor.py:701–899  ·  view source on GitHub ↗

r""" Split strings around given separator/delimiter. Splits the string in the Series/Index from the beginning, at the specified delimiter string. Parameters ---------- pat : str or compiled regex, optional String or regular expression to

(
        self,
        pat: str | re.Pattern | None = None,
        *,
        n=-1,
        expand: bool = False,
        regex: bool | None = None,
    )

Source from the content-addressed store, hash-verified

699
700 @forbid_nonstring_types(["bytes"])
701 def split(
702 self,
703 pat: str | re.Pattern | None = None,
704 *,
705 n=-1,
706 expand: bool = False,
707 regex: bool | None = None,
708 ):
709 r"""
710 Split strings around given separator/delimiter.
711
712 Splits the string in the Series/Index from the beginning,
713 at the specified delimiter string.
714
715 Parameters
716 ----------
717 pat : str or compiled regex, optional
718 String or regular expression to split on.
719 If not specified, split on whitespace.
720 n : int, default -1 (all)
721 Limit number of splits in output.
722 ``None``, 0 and -1 will be interpreted as return all splits.
723 expand : bool, default False
724 Expand the split strings into separate columns.
725
726 - If ``True``, return DataFrame/MultiIndex expanding dimensionality.
727 - If ``False``, return Series/Index, containing lists of strings.
728
729 regex : bool, default None
730 Determines if the passed-in pattern is a regular expression:
731
732 - If ``True``, assumes the passed-in pattern is a regular expression
733 - If ``False``, treats the pattern as a literal string.
734 - If ``None`` and `pat` length is 1, treats `pat` as a literal string.
735 - If ``None`` and `pat` length is not 1, treats `pat` as a regular
736 expression.
737 - Cannot be set to False if `pat` is a compiled regex
738
739 Returns
740 -------
741 Series, Index, DataFrame or MultiIndex
742 Type matches caller unless ``expand=True`` (see Notes).
743
744 Raises
745 ------
746 ValueError
747 * if `regex` is False and `pat` is a compiled regex
748
749 See Also
750 --------
751 Series.str.split : Split strings around given separator/delimiter.
752 Series.str.rsplit : Splits string around given separator/delimiter,
753 starting from the right.
754 Series.str.join : Join lists contained as elements in the Series/Index
755 with passed delimiter.
756 str.split : Standard library version for split.
757 str.rsplit : Standard library version for rsplit.
758

Callers 15

mainFunction · 0.80
conda_package_to_pipFunction · 0.80
get_toml_map_fromFunction · 0.80
get_yaml_map_fromFunction · 0.80
get_versions_from_ciFunction · 0.80
get_versions_from_tomlFunction · 0.80
mainFunction · 0.80
get_api_itemsFunction · 0.80
validate_pep8Method · 0.80

Calls 3

_wrap_resultMethod · 0.95
is_reFunction · 0.85
_str_splitMethod · 0.45

Tested by 15

check_resultsMethod · 0.64
test_empty_str_methodsFunction · 0.64
test_pipe_failuresFunction · 0.64
test_split_regexFunction · 0.64
test_split_blank_stringFunction · 0.64
test_split_maxsplitFunction · 0.64