2727
2828class TestDataFrameToCSV :
2929 def read_csv (self , path , ** kwargs ):
30- params = {"index_col" : 0 , "parse_dates" : True }
30+ params = {"index_col" : 0 }
3131 params .update (** kwargs )
3232
3333 return read_csv (path , ** params )
@@ -46,17 +46,17 @@ def test_to_csv_from_csv1(self, float_frame, datetime_frame):
4646 # freq does not roundtrip
4747 datetime_frame .index = datetime_frame .index ._with_freq (None )
4848 datetime_frame .to_csv (path )
49- recons = self .read_csv (path )
49+ recons = self .read_csv (path , parse_dates = True )
5050 tm .assert_frame_equal (datetime_frame , recons )
5151
5252 datetime_frame .to_csv (path , index_label = "index" )
53- recons = self .read_csv (path , index_col = None )
53+ recons = self .read_csv (path , index_col = None , parse_dates = True )
5454
5555 assert len (recons .columns ) == len (datetime_frame .columns ) + 1
5656
5757 # no index
5858 datetime_frame .to_csv (path , index = False )
59- recons = self .read_csv (path , index_col = None )
59+ recons = self .read_csv (path , index_col = None , parse_dates = True )
6060 tm .assert_almost_equal (datetime_frame .values , recons .values )
6161
6262 # corner case
@@ -514,7 +514,10 @@ def test_to_csv_multiindex(self, float_frame, datetime_frame):
514514 tsframe .index = MultiIndex .from_arrays (new_index )
515515
516516 tsframe .to_csv (path , index_label = ["time" , "foo" ])
517- recons = self .read_csv (path , index_col = [0 , 1 ])
517+ with tm .assert_produces_warning (
518+ UserWarning , match = "Could not infer format"
519+ ):
520+ recons = self .read_csv (path , index_col = [0 , 1 ], parse_dates = True )
518521
519522 # TODO to_csv drops column name
520523 tm .assert_frame_equal (tsframe , recons , check_names = False )
@@ -1056,7 +1059,7 @@ def test_to_csv_date_format(self, datetime_frame):
10561059
10571060 # test NaTs
10581061 nat_index = to_datetime (
1059- ["NaT" ] * 10 + ["2000-01-01" , "1/1/ 2000" , "1-1-2000 " ]
1062+ ["NaT" ] * 10 + ["2000-01-01" , "2000-01-01 " , "2000-01-01 " ]
10601063 )
10611064 nat_frame = DataFrame ({"A" : nat_index }, index = nat_index )
10621065 nat_frame .to_csv (path , date_format = "%Y-%m-%d" )
0 commit comments