@@ -559,64 +559,39 @@ def test_repeat(self):
559
559
exp = Series ([u ('a' ), u ('bb' ), NA , u ('cccc' ), NA , u ('dddddd' )])
560
560
tm .assert_series_equal (result , exp )
561
561
562
- def test_deprecated_match (self ):
563
- # Old match behavior, deprecated (but still default) in 0.13
562
+ def test_match (self ):
563
+ # New match behavior introduced in 0.13
564
564
values = Series (['fooBAD__barBAD' , NA , 'foo' ])
565
-
566
- with tm .assert_produces_warning ():
567
- result = values .str .match ('.*(BAD[_]+).*(BAD)' )
568
- exp = Series ([('BAD__' , 'BAD' ), NA , []])
569
- tm .assert_series_equal (result , exp )
570
-
571
- # mixed
572
- mixed = Series (['aBAD_BAD' , NA , 'BAD_b_BAD' , True , datetime .today (),
573
- 'foo' , None , 1 , 2. ])
574
-
575
- with tm .assert_produces_warning ():
576
- rs = Series (mixed ).str .match ('.*(BAD[_]+).*(BAD)' )
577
- xp = Series ([('BAD_' , 'BAD' ), NA , ('BAD_' , 'BAD' ),
578
- NA , NA , [], NA , NA , NA ])
579
- tm .assertIsInstance (rs , Series )
580
- tm .assert_series_equal (rs , xp )
581
-
582
- # unicode
583
- values = Series ([u ('fooBAD__barBAD' ), NA , u ('foo' )])
584
-
585
- with tm .assert_produces_warning ():
586
- result = values .str .match ('.*(BAD[_]+).*(BAD)' )
587
- exp = Series ([(u ('BAD__' ), u ('BAD' )), NA , []])
565
+ result = values .str .match ('.*(BAD[_]+).*(BAD)' )
566
+ exp = Series ([True , NA , False ])
588
567
tm .assert_series_equal (result , exp )
589
568
590
- def test_match (self ):
591
- # New match behavior introduced in 0.13
592
569
values = Series (['fooBAD__barBAD' , NA , 'foo' ])
593
- with tm .assert_produces_warning ():
594
- result = values .str .match ('.*(BAD[_]+).*(BAD)' , as_indexer = True )
570
+ result = values .str .match ('.*BAD[_]+.*BAD' )
595
571
exp = Series ([True , NA , False ])
596
572
tm .assert_series_equal (result , exp )
597
573
598
- # If no groups, use new behavior even when as_indexer is False.
599
- # (Old behavior is pretty much useless in this case.)
574
+ # test passing as_indexer still works but is ignored
600
575
values = Series (['fooBAD__barBAD' , NA , 'foo' ])
601
- result = values .str .match ('.*BAD[_]+.*BAD' , as_indexer = False )
602
576
exp = Series ([True , NA , False ])
577
+ with tm .assert_produces_warning (UserWarning ):
578
+ result = values .str .match ('.*BAD[_]+.*BAD' , as_indexer = True )
579
+ tm .assert_series_equal (result , exp )
580
+ with tm .assert_produces_warning (UserWarning ):
581
+ result = values .str .match ('.*BAD[_]+.*BAD' , as_indexer = False )
603
582
tm .assert_series_equal (result , exp )
604
583
605
584
# mixed
606
585
mixed = Series (['aBAD_BAD' , NA , 'BAD_b_BAD' , True , datetime .today (),
607
586
'foo' , None , 1 , 2. ])
608
-
609
- with tm .assert_produces_warning ():
610
- rs = Series (mixed ).str .match ('.*(BAD[_]+).*(BAD)' , as_indexer = True )
587
+ rs = Series (mixed ).str .match ('.*(BAD[_]+).*(BAD)' )
611
588
xp = Series ([True , NA , True , NA , NA , False , NA , NA , NA ])
612
589
tm .assertIsInstance (rs , Series )
613
590
tm .assert_series_equal (rs , xp )
614
591
615
592
# unicode
616
593
values = Series ([u ('fooBAD__barBAD' ), NA , u ('foo' )])
617
-
618
- with tm .assert_produces_warning ():
619
- result = values .str .match ('.*(BAD[_]+).*(BAD)' , as_indexer = True )
594
+ result = values .str .match ('.*(BAD[_]+).*(BAD)' )
620
595
exp = Series ([True , NA , False ])
621
596
tm .assert_series_equal (result , exp )
622
597
@@ -2610,11 +2585,12 @@ def test_match_findall_flags(self):
2610
2585
2611
2586
pat = r'([A-Z0-9._%+-]+)@([A-Z0-9.-]+)\.([A-Z]{2,4})'
2612
2587
2613
- with tm .assert_produces_warning (FutureWarning ):
2614
- result = data .str .match (pat , flags = re .IGNORECASE )
2615
-
2588
+ result = data .str .extract (pat , flags = re .IGNORECASE )
2616
2589
self .assertEqual (result [0 ], ('dave' , 'google' , 'com' ))
2617
2590
2591
+ result = data .str .match (pat , flags = re .IGNORECASE )
2592
+ self .assertEqual (result [0 ], True )
2593
+
2618
2594
result = data .str .findall (pat , flags = re .IGNORECASE )
2619
2595
self .assertEqual (result [0 ][0 ], ('dave' , 'google' , 'com' ))
2620
2596
0 commit comments