1212 Series ,
1313 _testing as tm ,
1414)
15+ from pandas .tests .strings import _convert_na_value
1516
1617
1718@pytest .mark .parametrize ("method" , ["split" , "rsplit" ])
@@ -20,9 +21,7 @@ def test_split(any_string_dtype, method):
2021
2122 result = getattr (values .str , method )("_" )
2223 exp = Series ([["a" , "b" , "c" ], ["c" , "d" , "e" ], np .nan , ["f" , "g" , "h" ]])
23- if values .dtype != object :
24- # GH#18463
25- exp = exp .fillna (pd .NA )
24+ exp = _convert_na_value (values , exp )
2625 tm .assert_series_equal (result , exp )
2726
2827
@@ -32,9 +31,7 @@ def test_split_more_than_one_char(any_string_dtype, method):
3231 values = Series (["a__b__c" , "c__d__e" , np .nan , "f__g__h" ], dtype = any_string_dtype )
3332 result = getattr (values .str , method )("__" )
3433 exp = Series ([["a" , "b" , "c" ], ["c" , "d" , "e" ], np .nan , ["f" , "g" , "h" ]])
35- if values .dtype != object :
36- # GH#18463
37- exp = exp .fillna (pd .NA )
34+ exp = _convert_na_value (values , exp )
3835 tm .assert_series_equal (result , exp )
3936
4037 result = getattr (values .str , method )("__" , expand = False )
@@ -46,9 +43,7 @@ def test_split_more_regex_split(any_string_dtype):
4643 values = Series (["a,b_c" , "c_d,e" , np .nan , "f,g,h" ], dtype = any_string_dtype )
4744 result = values .str .split ("[,_]" )
4845 exp = Series ([["a" , "b" , "c" ], ["c" , "d" , "e" ], np .nan , ["f" , "g" , "h" ]])
49- if values .dtype != object :
50- # GH#18463
51- exp = exp .fillna (pd .NA )
46+ exp = _convert_na_value (values , exp )
5247 tm .assert_series_equal (result , exp )
5348
5449
@@ -128,9 +123,7 @@ def test_rsplit(any_string_dtype):
128123 values = Series (["a,b_c" , "c_d,e" , np .nan , "f,g,h" ], dtype = any_string_dtype )
129124 result = values .str .rsplit ("[,_]" )
130125 exp = Series ([["a,b_c" ], ["c_d,e" ], np .nan , ["f,g,h" ]])
131- if values .dtype != object :
132- # GH#18463
133- exp = exp .fillna (pd .NA )
126+ exp = _convert_na_value (values , exp )
134127 tm .assert_series_equal (result , exp )
135128
136129
@@ -139,9 +132,7 @@ def test_rsplit_max_number(any_string_dtype):
139132 values = Series (["a_b_c" , "c_d_e" , np .nan , "f_g_h" ], dtype = any_string_dtype )
140133 result = values .str .rsplit ("_" , n = 1 )
141134 exp = Series ([["a_b" , "c" ], ["c_d" , "e" ], np .nan , ["f_g" , "h" ]])
142- if values .dtype != object :
143- # GH#18463
144- exp = exp .fillna (pd .NA )
135+ exp = _convert_na_value (values , exp )
145136 tm .assert_series_equal (result , exp )
146137
147138
@@ -455,9 +446,7 @@ def test_partition_series_more_than_one_char(method, exp, any_string_dtype):
455446 s = Series (["a__b__c" , "c__d__e" , np .nan , "f__g__h" , None ], dtype = any_string_dtype )
456447 result = getattr (s .str , method )("__" , expand = False )
457448 expected = Series (exp )
458- if s .dtype != object :
459- # GH#18463
460- expected = expected .fillna (pd .NA )
449+ expected = _convert_na_value (s , expected )
461450 tm .assert_series_equal (result , expected )
462451
463452
@@ -480,9 +469,7 @@ def test_partition_series_none(any_string_dtype, method, exp):
480469 s = Series (["a b c" , "c d e" , np .nan , "f g h" , None ], dtype = any_string_dtype )
481470 result = getattr (s .str , method )(expand = False )
482471 expected = Series (exp )
483- if s .dtype != object :
484- # GH#18463
485- expected = expected .fillna (pd .NA )
472+ expected = _convert_na_value (s , expected )
486473 tm .assert_series_equal (result , expected )
487474
488475
@@ -505,9 +492,7 @@ def test_partition_series_not_split(any_string_dtype, method, exp):
505492 s = Series (["abc" , "cde" , np .nan , "fgh" , None ], dtype = any_string_dtype )
506493 result = getattr (s .str , method )("_" , expand = False )
507494 expected = Series (exp )
508- if s .dtype != object :
509- # GH#18463
510- expected = expected .fillna (pd .NA )
495+ expected = _convert_na_value (s , expected )
511496 tm .assert_series_equal (result , expected )
512497
513498
@@ -531,9 +516,7 @@ def test_partition_series_unicode(any_string_dtype, method, exp):
531516
532517 result = getattr (s .str , method )("_" , expand = False )
533518 expected = Series (exp )
534- if s .dtype != object :
535- # GH#18463
536- expected = expected .fillna (pd .NA )
519+ expected = _convert_na_value (s , expected )
537520 tm .assert_series_equal (result , expected )
538521
539522
0 commit comments