@@ -889,20 +889,24 @@ def test_concat_same_type_different_freq(self, unit):
889
889
890
890
tm .assert_datetime_array_equal (result , expected )
891
891
892
- def test_strftime (self , arr1d ):
892
+ def test_strftime (self , arr1d , using_infer_string ):
893
893
arr = arr1d
894
894
895
895
result = arr .strftime ("%Y %b" )
896
896
expected = np .array ([ts .strftime ("%Y %b" ) for ts in arr ], dtype = object )
897
- tm .assert_numpy_array_equal (result , expected )
897
+ if using_infer_string :
898
+ expected = pd .array (expected , dtype = pd .StringDtype (na_value = np .nan ))
899
+ tm .assert_equal (result , expected )
898
900
899
- def test_strftime_nat (self ):
901
+ def test_strftime_nat (self , using_infer_string ):
900
902
# GH 29578
901
903
arr = DatetimeIndex (["2019-01-01" , NaT ])._data
902
904
903
905
result = arr .strftime ("%Y-%m-%d" )
904
906
expected = np .array (["2019-01-01" , np .nan ], dtype = object )
905
- tm .assert_numpy_array_equal (result , expected )
907
+ if using_infer_string :
908
+ expected = pd .array (expected , dtype = pd .StringDtype (na_value = np .nan ))
909
+ tm .assert_equal (result , expected )
906
910
907
911
908
912
class TestTimedeltaArray (SharedTests ):
@@ -1159,20 +1163,24 @@ def test_array_interface(self, arr1d):
1159
1163
expected = np .asarray (arr ).astype ("S20" )
1160
1164
tm .assert_numpy_array_equal (result , expected )
1161
1165
1162
- def test_strftime (self , arr1d ):
1166
+ def test_strftime (self , arr1d , using_infer_string ):
1163
1167
arr = arr1d
1164
1168
1165
1169
result = arr .strftime ("%Y" )
1166
1170
expected = np .array ([per .strftime ("%Y" ) for per in arr ], dtype = object )
1167
- tm .assert_numpy_array_equal (result , expected )
1171
+ if using_infer_string :
1172
+ expected = pd .array (expected , dtype = pd .StringDtype (na_value = np .nan ))
1173
+ tm .assert_equal (result , expected )
1168
1174
1169
- def test_strftime_nat (self ):
1175
+ def test_strftime_nat (self , using_infer_string ):
1170
1176
# GH 29578
1171
1177
arr = PeriodArray (PeriodIndex (["2019-01-01" , NaT ], dtype = "period[D]" ))
1172
1178
1173
1179
result = arr .strftime ("%Y-%m-%d" )
1174
1180
expected = np .array (["2019-01-01" , np .nan ], dtype = object )
1175
- tm .assert_numpy_array_equal (result , expected )
1181
+ if using_infer_string :
1182
+ expected = pd .array (expected , dtype = pd .StringDtype (na_value = np .nan ))
1183
+ tm .assert_equal (result , expected )
1176
1184
1177
1185
1178
1186
@pytest .mark .parametrize (
0 commit comments