@@ -813,20 +813,11 @@ def test_series_roundtrip_simple(self, orient, numpy):
813
813
@pytest .mark .parametrize ("dtype" , [False , None ])
814
814
@pytest .mark .parametrize ("numpy" , [True , False ])
815
815
def test_series_roundtrip_object (self , orient , numpy , dtype ):
816
- # TODO: see why tm.makeObjectSeries provides back DTA
817
- dtSeries = Series (
818
- [str (d ) for d in self .objSeries ],
819
- index = self .objSeries .index ,
820
- name = self .objSeries .name ,
821
- )
822
- data = dtSeries .to_json (orient = orient )
816
+ data = self .objSeries .to_json (orient = orient )
823
817
result = pd .read_json (
824
818
data , typ = "series" , orient = orient , numpy = numpy , dtype = dtype
825
819
)
826
- if dtype is False :
827
- expected = dtSeries .copy ()
828
- else :
829
- expected = self .objSeries .copy ()
820
+ expected = self .objSeries .copy ()
830
821
831
822
if not numpy and PY35 and orient in ("index" , "columns" ):
832
823
expected = expected .sort_index ()
@@ -897,6 +888,19 @@ def test_series_with_dtype(self):
897
888
expected = Series ([4 ] * 3 )
898
889
assert_series_equal (result , expected )
899
890
891
+ @pytest .mark .parametrize (
892
+ "dtype,expected" ,
893
+ [
894
+ (True , Series (["2000-01-01" ], dtype = "datetime64[ns]" )),
895
+ (False , Series ([946684800000 ])),
896
+ ],
897
+ )
898
+ def test_series_with_dtype_datetime (self , dtype , expected ):
899
+ s = Series (["2000-01-01" ], dtype = "datetime64[ns]" )
900
+ data = s .to_json ()
901
+ result = pd .read_json (data , typ = "series" , dtype = dtype )
902
+ assert_series_equal (result , expected )
903
+
900
904
def test_frame_from_json_precise_float (self ):
901
905
df = DataFrame ([[4.56 , 4.56 , 4.56 ], [4.56 , 4.56 , 4.56 ]])
902
906
result = read_json (df .to_json (), precise_float = True )
0 commit comments