@@ -659,7 +659,7 @@ def cat(
659
659
660
660
Parameters
661
661
----------
662
- pat : str or compiled regex , optional
662
+ pat : str%(pat_regex)s , optional
663
663
String or regular expression to split on.
664
664
If not specified, split on whitespace.
665
665
n : int, default -1 (all)
@@ -671,26 +671,14 @@ def cat(
671
671
- If ``True``, return DataFrame/MultiIndex expanding dimensionality.
672
672
- If ``False``, return Series/Index, containing lists of strings.
673
673
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
684
675
685
676
Returns
686
677
-------
687
678
Series, Index, DataFrame or MultiIndex
688
679
Type matches caller unless ``expand=True`` (see Notes).
689
680
690
- Raises
691
- ------
692
- ValueError
693
- * if `regex` is False and `pat` is a compiled regex
681
+ %(raises_split)s
694
682
695
683
See Also
696
684
--------
@@ -714,8 +702,7 @@ def cat(
714
702
If using ``expand=True``, Series and Index callers return DataFrame and
715
703
MultiIndex objects, respectively.
716
704
717
- Use of `regex=False` with a `pat` as a compiled regex will raise
718
- an error.
705
+ %(regex_pat_note)s
719
706
720
707
Examples
721
708
--------
@@ -831,7 +818,34 @@ def cat(
831
818
0 foojpgbar.jpg
832
819
"""
833
820
834
- @Appender (_shared_docs ["str_split" ] % {"side" : "beginning" , "method" : "split" })
821
+ @Appender (
822
+ _shared_docs ["str_split" ]
823
+ % {
824
+ "side" : "beginning" ,
825
+ "pat_regex" : " or compiled regex" ,
826
+ "regex_argument" : """
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
+ Raises
840
+ ------
841
+ ValueError
842
+ * if `regex` is False and `pat` is a compiled regex
843
+ """ ,
844
+ "regex_pat_note" : "Use of `regex =False` with a `pat` as a "
845
+ "compiled regex will raise an error." ,
846
+ "method" : "split" ,
847
+ }
848
+ )
835
849
@forbid_nonstring_types (["bytes" ])
836
850
def split (
837
851
self ,
@@ -850,7 +864,17 @@ def split(
850
864
result = self ._data .array ._str_split (pat , n , expand , regex )
851
865
return self ._wrap_result (result , returns_string = expand , expand = expand )
852
866
853
- @Appender (_shared_docs ["str_split" ] % {"side" : "end" , "method" : "rsplit" })
867
+ @Appender (
868
+ _shared_docs ["str_split" ]
869
+ % {
870
+ "side" : "end" ,
871
+ "pat_regex" : "" ,
872
+ "regex_argument" : "" ,
873
+ "raises_split" : "" ,
874
+ "regex_pat_note" : "" ,
875
+ "method" : "rsplit" ,
876
+ }
877
+ )
854
878
@forbid_nonstring_types (["bytes" ])
855
879
def rsplit (self , pat = None , n = - 1 , expand = False ):
856
880
result = self ._data .array ._str_rsplit (pat , n = n )
0 commit comments