@@ -1979,21 +1979,26 @@ def test_str_find_large_start():
19791979@pytest .mark .xfail (
19801980 pa_version_under13p0 , reason = "https://github.com/apache/arrow/issues/36311"
19811981)
1982- def test_str_find_e2e ():
1983- string = "abcaadef"
1984- s = pd .Series ([string ], dtype = ArrowDtype (pa .string ()))
1985- offsets = list (range (- 15 , 15 )) + [None ]
1986- substrings = [string [x :y ] for x , y in combinations (range (len (string ) + 1 ), r = 2 )] + [
1982+ @pytest .mark .parametrize ("start" , list (range (- 15 , 15 )) + [None ])
1983+ @pytest .mark .parametrize ("end" , list (range (- 15 , 15 )) + [None ])
1984+ @pytest .mark .parametrize (
1985+ "sub" ,
1986+ ["abcaadef" [x :y ] for x , y in combinations (range (len ("abcaadef" ) + 1 ), r = 2 )]
1987+ + [
19871988 "" ,
19881989 "az" ,
19891990 "abce" ,
1990- ]
1991- for start in offsets :
1992- for end in offsets :
1993- for sub in substrings :
1994- result = s .str .find (sub , start , end )
1995- expected = pd .Series ([string .find (sub , start , end )], dtype = result .dtype )
1996- tm .assert_series_equal (result , expected )
1991+ ],
1992+ )
1993+ def test_str_find_e2e (start , end , sub ):
1994+ s = pd .Series (
1995+ ["abcaadef" , "abc" , "abcdeddefgj8292" , "ab" , "a" , "" ],
1996+ dtype = ArrowDtype (pa .string ()),
1997+ )
1998+ object_series = s .astype (pd .StringDtype ())
1999+ result = s .str .find (sub , start , end )
2000+ expected = object_series .str .find (sub , start , end ).astype (result .dtype )
2001+ tm .assert_series_equal (result , expected )
19972002
19982003
19992004def test_str_find_negative_start_negative_end_no_match ():
0 commit comments