Split strings around given separator/delimiter. Splits the string in the Series/Index from the end, at the specified delimiter string. Parameters ---------- pat : str, optional String to split on. If not specified, split on w
(self, pat=None, *, n=-1, expand: bool = False)
| 900 | |
| 901 | @forbid_nonstring_types(["bytes"]) |
| 902 | def rsplit(self, pat=None, *, n=-1, expand: bool = False): |
| 903 | """ |
| 904 | Split strings around given separator/delimiter. |
| 905 | |
| 906 | Splits the string in the Series/Index from the end, |
| 907 | at the specified delimiter string. |
| 908 | |
| 909 | Parameters |
| 910 | ---------- |
| 911 | pat : str, optional |
| 912 | String to split on. |
| 913 | If not specified, split on whitespace. |
| 914 | n : int, default -1 (all) |
| 915 | Limit number of splits in output. |
| 916 | ``None``, 0 and -1 will be interpreted as return all splits. |
| 917 | expand : bool, default False |
| 918 | Expand the split strings into separate columns. |
| 919 | |
| 920 | - If ``True``, return DataFrame/MultiIndex expanding dimensionality. |
| 921 | - If ``False``, return Series/Index, containing lists of strings. |
| 922 | |
| 923 | Returns |
| 924 | ------- |
| 925 | Series, Index, DataFrame or MultiIndex |
| 926 | Type matches caller unless ``expand=True`` (see Notes). |
| 927 | |
| 928 | See Also |
| 929 | -------- |
| 930 | Series.str.split : Split strings around given separator/delimiter. |
| 931 | Series.str.rsplit : Splits string around given separator/delimiter, |
| 932 | starting from the right. |
| 933 | Series.str.join : Join lists contained as elements in the Series/Index |
| 934 | with passed delimiter. |
| 935 | str.split : Standard library version for split. |
| 936 | str.rsplit : Standard library version for rsplit. |
| 937 | |
| 938 | Notes |
| 939 | ----- |
| 940 | The handling of the `n` keyword depends on the number of found splits: |
| 941 | |
| 942 | - If found splits > `n`, make first `n` splits only |
| 943 | - If found splits <= `n`, make all splits |
| 944 | - If for a certain row the number of found splits < `n`, |
| 945 | append `None` for padding up to `n` if ``expand=True`` |
| 946 | |
| 947 | If using ``expand=True``, Series and Index callers return DataFrame and |
| 948 | MultiIndex objects, respectively. |
| 949 | |
| 950 | Examples |
| 951 | -------- |
| 952 | >>> s = pd.Series( |
| 953 | ... [ |
| 954 | ... "this is a regular sentence", |
| 955 | ... "https://docs.python.org/3/tutorial/index.html", |
| 956 | ... np.nan, |
| 957 | ... ] |
| 958 | ... ) |
| 959 | >>> s |