@@ -744,7 +744,10 @@ def test_astype_tz_object_conversion(self, tz):
744
744
tm .assert_frame_equal (result , expected )
745
745
746
746
def test_astype_dt64_to_string (
747
- self , frame_or_series , tz_naive_fixture , using_infer_string
747
+ self ,
748
+ frame_or_series ,
749
+ tz_naive_fixture ,
750
+ string_dtype_no_object ,
748
751
):
749
752
# GH#41409
750
753
tz = tz_naive_fixture
@@ -754,28 +757,17 @@ def test_astype_dt64_to_string(
754
757
dta [0 ] = NaT
755
758
756
759
obj = frame_or_series (dta )
757
- result = obj .astype ("string" )
760
+ result = obj .astype (string_dtype_no_object )
758
761
759
762
# Check that Series/DataFrame.astype matches DatetimeArray.astype
760
- expected = frame_or_series (dta .astype ("string" ))
763
+ expected = frame_or_series (dta .astype (string_dtype_no_object ))
761
764
tm .assert_equal (result , expected )
762
765
763
766
item = result .iloc [0 ]
764
767
if frame_or_series is DataFrame :
765
768
item = item .iloc [0 ]
766
769
767
- assert item is pd .NA
768
-
769
- # Check that Series/DataFrame.astype matches DatetimeArray.astype
770
- result = obj .astype ("str" )
771
- expected = frame_or_series (dta .astype ("str" ))
772
- tm .assert_equal (result , expected )
773
-
774
- item = result .iloc [0 ]
775
- if frame_or_series is DataFrame :
776
- item = item .iloc [0 ]
777
- if using_infer_string :
778
- assert item is np .nan
770
+ assert item is string_dtype_no_object .na_value
779
771
780
772
def test_astype_td64_to_string (self , frame_or_series ):
781
773
# GH#41409
0 commit comments