@@ -358,47 +358,43 @@ def test_to_datetime_dt64s(self, cache):
358
358
def test_to_datetime_array_of_dt64s (self , cache ):
359
359
dts = [np .datetime64 ('2000-01-01' ), np .datetime64 ('2000-01-02' ), ]
360
360
361
- with tm .assert_produces_warning (FutureWarning ):
362
-
363
- # Assuming all datetimes are in bounds, to_datetime() returns
364
- # an array that is equal to Timestamp() parsing
365
- tm .assert_numpy_array_equal (
366
- pd .to_datetime (dts , box = False , cache = cache ),
367
- np .array ([Timestamp (x ).asm8 for x in dts ])
368
- )
361
+ # Assuming all datetimes are in bounds, to_datetime() returns
362
+ # an array that is equal to Timestamp() parsing
363
+ tm .assert_numpy_array_equal (
364
+ pd .to_datetime (dts , cache = cache ).to_numpy (),
365
+ np .array ([Timestamp (x ).asm8 for x in dts ])
366
+ )
369
367
370
- # A list of datetimes where the last one is out of bounds
371
- dts_with_oob = dts + [np .datetime64 ('9999-01-01' )]
368
+ # A list of datetimes where the last one is out of bounds
369
+ dts_with_oob = dts + [np .datetime64 ('9999-01-01' )]
372
370
373
- pytest .raises (ValueError , pd . to_datetime , dts_with_oob ,
374
- errors = 'raise' )
371
+ with pytest .raises (ValueError ):
372
+ pd . to_datetime ( dts_with_oob )
375
373
376
- with tm .assert_produces_warning (FutureWarning ):
377
- tm .assert_numpy_array_equal (
378
- pd .to_datetime (dts_with_oob , box = False , errors = 'coerce' ,
379
- cache = cache ),
380
- np .array (
381
- [
382
- Timestamp (dts_with_oob [0 ]).asm8 ,
383
- Timestamp (dts_with_oob [1 ]).asm8 ,
384
- tslib .iNaT ,
385
- ],
386
- dtype = 'M8'
387
- )
374
+ tm .assert_numpy_array_equal (
375
+ pd .to_datetime (dts_with_oob , errors = 'coerce' ,
376
+ cache = cache ).to_numpy (),
377
+ np .array (
378
+ [
379
+ Timestamp (dts_with_oob [0 ]).asm8 ,
380
+ Timestamp (dts_with_oob [1 ]).asm8 ,
381
+ tslib .iNaT ,
382
+ ],
383
+ dtype = 'M8'
388
384
)
389
-
390
- with tm .assert_produces_warning (FutureWarning ):
391
- # With errors='ignore', out of bounds datetime64s
392
- # are converted to their .item(), which depending on the version of
393
- # numpy is either a python datetime.datetime or datetime.date
394
- tm .assert_numpy_array_equal (
395
- pd .to_datetime (dts_with_oob , box = False , errors = 'ignore' ,
396
- cache = cache ),
397
- np .array (
398
- [dt .item () for dt in dts_with_oob ],
399
- dtype = 'O'
400
- )
385
+ )
386
+
387
+ # With errors='ignore', out of bounds datetime64s
388
+ # are converted to their .item(), which depending on the version of
389
+ # numpy is either a python datetime.datetime or datetime.date
390
+ tm .assert_numpy_array_equal (
391
+ pd .to_datetime (dts_with_oob , errors = 'ignore' ,
392
+ cache = cache ).to_numpy (),
393
+ np .array (
394
+ [dt .item () for dt in dts_with_oob ],
395
+ dtype = 'O'
401
396
)
397
+ )
402
398
403
399
@pytest .mark .parametrize ('cache' , [True , False ])
404
400
def test_to_datetime_tz (self , cache ):
0 commit comments