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,
)
| 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 |