@@ -659,7 +659,7 @@ def cat(
659659
660660 Parameters
661661 ----------
662- pat : str or compiled regex , optional
662+ pat : str%(pat_regex)s , optional
663663 String or regular expression to split on.
664664 If not specified, split on whitespace.
665665 n : int, default -1 (all)
@@ -671,26 +671,14 @@ def cat(
671671 - If ``True``, return DataFrame/MultiIndex expanding dimensionality.
672672 - If ``False``, return Series/Index, containing lists of strings.
673673
674- regex : bool, default None
675- Determines if the passed-in pattern is a regular expression:
676-
677- - If ``True``, assumes the passed-in pattern is a regular expression
678- - If ``False``, treats the pattern as a literal string.
679- - If ``None`` and `pat` length is 1, treats `pat` as a literal string.
680- - If ``None`` and `pat` length is not 1, treats `pat` as a regular expression.
681- - Cannot be set to False if `pat` is a compiled regex
682-
683- .. versionadded:: 1.4.0
674+ %(regex_argument)s
684675
685676 Returns
686677 -------
687678 Series, Index, DataFrame or MultiIndex
688679 Type matches caller unless ``expand=True`` (see Notes).
689680
690- Raises
691- ------
692- ValueError
693- * if `regex` is False and `pat` is a compiled regex
681+ %(raises_split)s
694682
695683 See Also
696684 --------
@@ -714,8 +702,7 @@ def cat(
714702 If using ``expand=True``, Series and Index callers return DataFrame and
715703 MultiIndex objects, respectively.
716704
717- Use of `regex=False` with a `pat` as a compiled regex will raise
718- an error.
705+ %(regex_pat_note)s
719706
720707 Examples
721708 --------
@@ -831,7 +818,36 @@ def cat(
831818 0 foojpgbar.jpg
832819 """
833820
834- @Appender (_shared_docs ["str_split" ] % {"side" : "beginning" , "method" : "split" })
821+ @Appender (_shared_docs ["str_split" ]
822+ % {
823+ "side" : "beginning" ,
824+ "pat_regex" : " or compiled regex" ,
825+ "regex_argument" :
826+ """
827+ regex : bool, default None
828+ Determines if the passed-in pattern is a regular expression:
829+
830+ - If ``True``, assumes the passed-in pattern is a regular expression
831+ - If ``False``, treats the pattern as a literal string.
832+ - If ``None`` and `pat` length is 1, treats `pat` as a literal string.
833+ - If ``None`` and `pat` length is not 1, treats `pat` as a regular expression.
834+ - Cannot be set to False if `pat` is a compiled regex
835+
836+ .. versionadded:: 1.4.0
837+ """ ,
838+ "raises_split" :
839+ """
840+ Raises
841+ ------
842+ ValueError
843+ * if `regex` is False and `pat` is a compiled regex
844+ """ ,
845+ "regex_pat_note" : "Use of `regex =False` with a `pat` as a compiled regex"
846+ " will raise an error." ,
847+ "method" : "split"
848+ }
849+ )
850+
835851 @forbid_nonstring_types (["bytes" ])
836852 def split (
837853 self ,
@@ -850,7 +866,16 @@ def split(
850866 result = self ._data .array ._str_split (pat , n , expand , regex )
851867 return self ._wrap_result (result , returns_string = expand , expand = expand )
852868
853- @Appender (_shared_docs ["str_split" ] % {"side" : "end" , "method" : "rsplit" })
869+ @Appender (_shared_docs ["str_split" ]
870+ % {
871+ "side" : "end" ,
872+ "pat_regex" : "" ,
873+ "regex_argument" : "" ,
874+ "raises_split" : "" ,
875+ "regex_pat_note" : "" ,
876+ "method" : "rsplit"
877+ }
878+ )
854879 @forbid_nonstring_types (["bytes" ])
855880 def rsplit (self , pat = None , n = - 1 , expand = False ):
856881 result = self ._data .array ._str_rsplit (pat , n = n )
0 commit comments