@@ -306,7 +306,7 @@ def str_endswith(arr, pat, na=np.nan):
306
306
307
307
308
308
def str_replace (arr , pat , repl , n = - 1 , case = None , flags = 0 ):
309
- """
309
+ r """
310
310
Replace occurrences of pattern/regex in the Series/Index with
311
311
some other string. Equivalent to :meth:`str.replace` or
312
312
:func:`re.sub`.
@@ -598,7 +598,7 @@ def _str_extract_frame(arr, pat, flags=0):
598
598
599
599
600
600
def str_extract (arr , pat , flags = 0 , expand = None ):
601
- """
601
+ r """
602
602
For each subject string in the Series, extract groups from the
603
603
first match of regular expression pat.
604
604
@@ -635,23 +635,23 @@ def str_extract(arr, pat, flags=0, expand=None):
635
635
Non-matches will be NaN.
636
636
637
637
>>> s = Series(['a1', 'b2', 'c3'])
638
- >>> s.str.extract('([ab])(\d)')
638
+ >>> s.str.extract(r '([ab])(\d)')
639
639
0 1
640
640
0 a 1
641
641
1 b 2
642
642
2 NaN NaN
643
643
644
644
A pattern may contain optional groups.
645
645
646
- >>> s.str.extract('([ab])?(\d)')
646
+ >>> s.str.extract(r '([ab])?(\d)')
647
647
0 1
648
648
0 a 1
649
649
1 b 2
650
650
2 NaN 3
651
651
652
652
Named groups will become column names in the result.
653
653
654
- >>> s.str.extract('(?P<letter>[ab])(?P<digit>\d)')
654
+ >>> s.str.extract(r '(?P<letter>[ab])(?P<digit>\d)')
655
655
letter digit
656
656
0 a 1
657
657
1 b 2
@@ -660,15 +660,15 @@ def str_extract(arr, pat, flags=0, expand=None):
660
660
A pattern with one group will return a DataFrame with one column
661
661
if expand=True.
662
662
663
- >>> s.str.extract('[ab](\d)', expand=True)
663
+ >>> s.str.extract(r '[ab](\d)', expand=True)
664
664
0
665
665
0 1
666
666
1 2
667
667
2 NaN
668
668
669
669
A pattern with one group will return a Series if expand=False.
670
670
671
- >>> s.str.extract('[ab](\d)', expand=False)
671
+ >>> s.str.extract(r '[ab](\d)', expand=False)
672
672
0 1
673
673
1 2
674
674
2 NaN
@@ -694,7 +694,7 @@ def str_extract(arr, pat, flags=0, expand=None):
694
694
695
695
696
696
def str_extractall (arr , pat , flags = 0 ):
697
- """
697
+ r """
698
698
For each subject string in the Series, extract groups from all
699
699
matches of regular expression pat. When each subject string in the
700
700
Series has exactly one match, extractall(pat).xs(0, level='match')
@@ -728,7 +728,7 @@ def str_extractall(arr, pat, flags=0):
728
728
Indices with no matches will not appear in the result.
729
729
730
730
>>> s = Series(["a1a2", "b1", "c1"], index=["A", "B", "C"])
731
- >>> s.str.extractall("[ab](\d)")
731
+ >>> s.str.extractall(r "[ab](\d)")
732
732
0
733
733
match
734
734
A 0 1
@@ -737,7 +737,7 @@ def str_extractall(arr, pat, flags=0):
737
737
738
738
Capture group names are used for column names of the result.
739
739
740
- >>> s.str.extractall("[ab](?P<digit>\d)")
740
+ >>> s.str.extractall(r "[ab](?P<digit>\d)")
741
741
digit
742
742
match
743
743
A 0 1
@@ -746,7 +746,7 @@ def str_extractall(arr, pat, flags=0):
746
746
747
747
A pattern with two groups will return a DataFrame with two columns.
748
748
749
- >>> s.str.extractall("(?P<letter>[ab])(?P<digit>\d)")
749
+ >>> s.str.extractall(r "(?P<letter>[ab])(?P<digit>\d)")
750
750
letter digit
751
751
match
752
752
A 0 a 1
@@ -755,7 +755,7 @@ def str_extractall(arr, pat, flags=0):
755
755
756
756
Optional groups that do not match are NaN in the result.
757
757
758
- >>> s.str.extractall("(?P<letter>[ab])?(?P<digit>\d)")
758
+ >>> s.str.extractall(r "(?P<letter>[ab])?(?P<digit>\d)")
759
759
letter digit
760
760
match
761
761
A 0 a 1
0 commit comments