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