@@ -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)
@@ -670,28 +670,12 @@ def cat(
670
670
671
671
- If ``True``, return DataFrame/MultiIndex expanding dimensionality.
672
672
- If ``False``, return Series/Index, containing lists of strings.
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
684
-
673
+ %(regex_argument)s
685
674
Returns
686
675
-------
687
676
Series, Index, DataFrame or MultiIndex
688
677
Type matches caller unless ``expand=True`` (see Notes).
689
-
690
- Raises
691
- ------
692
- ValueError
693
- * if `regex` is False and `pat` is a compiled regex
694
-
678
+ %(raises_split)s
695
679
See Also
696
680
--------
697
681
Series.str.split : Split strings around given separator/delimiter.
@@ -713,10 +697,7 @@ def cat(
713
697
714
698
If using ``expand=True``, Series and Index callers return DataFrame and
715
699
MultiIndex objects, respectively.
716
-
717
- Use of `regex=False` with a `pat` as a compiled regex will raise
718
- an error.
719
-
700
+ %(regex_pat_note)s
720
701
Examples
721
702
--------
722
703
>>> s = pd.Series(
@@ -831,7 +812,35 @@ def cat(
831
812
0 foojpgbar.jpg
832
813
"""
833
814
834
- @Appender (_shared_docs ["str_split" ] % {"side" : "beginning" , "method" : "split" })
815
+ @Appender (
816
+ _shared_docs ["str_split" ]
817
+ % {
818
+ "side" : "beginning" ,
819
+ "pat_regex" : " or compiled regex" ,
820
+ "regex_argument" : """
821
+ regex : bool, default None
822
+ Determines if the passed-in pattern is a regular expression:
823
+
824
+ - If ``True``, assumes the passed-in pattern is a regular expression
825
+ - If ``False``, treats the pattern as a literal string.
826
+ - If ``None`` and `pat` length is 1, treats `pat` as a literal string.
827
+ - If ``None`` and `pat` length is not 1, treats `pat` as a regular expression.
828
+ - Cannot be set to False if `pat` is a compiled regex
829
+
830
+ .. versionadded:: 1.4.0
831
+ """ ,
832
+ "raises_split" : """
833
+ Raises
834
+ ------
835
+ ValueError
836
+ * if `regex` is False and `pat` is a compiled regex
837
+ """ ,
838
+ "regex_pat_note" : """
839
+ Use of `regex =False` with a `pat` as a compiled regex will raise an error.
840
+ """ ,
841
+ "method" : "split" ,
842
+ }
843
+ )
835
844
@forbid_nonstring_types (["bytes" ])
836
845
def split (
837
846
self ,
@@ -850,7 +859,17 @@ def split(
850
859
result = self ._data .array ._str_split (pat , n , expand , regex )
851
860
return self ._wrap_result (result , returns_string = expand , expand = expand )
852
861
853
- @Appender (_shared_docs ["str_split" ] % {"side" : "end" , "method" : "rsplit" })
862
+ @Appender (
863
+ _shared_docs ["str_split" ]
864
+ % {
865
+ "side" : "end" ,
866
+ "pat_regex" : "" ,
867
+ "regex_argument" : "" ,
868
+ "raises_split" : "" ,
869
+ "regex_pat_note" : "" ,
870
+ "method" : "rsplit" ,
871
+ }
872
+ )
854
873
@forbid_nonstring_types (["bytes" ])
855
874
def rsplit (self , pat = None , n = - 1 , expand = False ):
856
875
result = self ._data .array ._str_rsplit (pat , n = n )
0 commit comments