@@ -34,7 +34,6 @@ from pandas._libs.tslibs.np_datetime cimport (
34
34
NPY_DATETIMEUNIT,
35
35
NPY_FR_ns,
36
36
check_dts_bounds,
37
- get_datetime64_value,
38
37
npy_datetimestruct,
39
38
npy_datetimestruct_to_datetime,
40
39
pandas_datetime_to_datetimestruct,
@@ -542,16 +541,6 @@ cpdef array_to_datetime(
542
541
543
542
cnp.PyArray_MultiIter_NEXT(mi)
544
543
545
- except OutOfBoundsDatetime as ex:
546
- ex.args = (f" {ex}, at position {i}" ,)
547
- if is_coerce:
548
- iresult[i] = NPY_NAT
549
- cnp.PyArray_MultiIter_NEXT(mi)
550
- continue
551
- elif is_raise:
552
- raise
553
- return ignore_errors_out_of_bounds_fallback(values), tz_out
554
-
555
544
except (TypeError , OverflowError , ValueError ) as ex:
556
545
ex.args = (f" {ex}, at position {i}" ,)
557
546
if is_coerce:
@@ -578,55 +567,6 @@ cpdef array_to_datetime(
578
567
return result, tz_out
579
568
580
569
581
- @ cython.wraparound (False )
582
- @ cython.boundscheck (False )
583
- cdef ndarray ignore_errors_out_of_bounds_fallback(ndarray values):
584
- """
585
- Fallback for array_to_datetime if an OutOfBoundsDatetime is raised
586
- and errors == "ignore"
587
-
588
- Parameters
589
- ----------
590
- values : ndarray[object]
591
-
592
- Returns
593
- -------
594
- ndarray[object]
595
- """
596
- cdef:
597
- Py_ssize_t i, n = values.size
598
- object val
599
- cnp.broadcast mi
600
- ndarray[object ] oresult
601
- ndarray oresult_nd
602
-
603
- oresult_nd = cnp.PyArray_EMPTY(values.ndim, values.shape, cnp.NPY_OBJECT, 0 )
604
- mi = cnp.PyArray_MultiIterNew2(oresult_nd, values)
605
- oresult = oresult_nd.ravel()
606
-
607
- for i in range (n):
608
- # Analogous to `val = values[i]`
609
- val = < object > (< PyObject** > cnp.PyArray_MultiIter_DATA(mi, 1 ))[0 ]
610
-
611
- # set as nan except if its a NaT
612
- if checknull_with_nat_and_na(val):
613
- if isinstance (val, float ):
614
- oresult[i] = np.nan
615
- else :
616
- oresult[i] = < object > NaT
617
- elif is_datetime64_object(val):
618
- if get_datetime64_value(val) == NPY_NAT:
619
- oresult[i] = < object > NaT
620
- else :
621
- oresult[i] = val.item()
622
- else :
623
- oresult[i] = val
624
-
625
- cnp.PyArray_MultiIter_NEXT(mi)
626
-
627
- return oresult
628
-
629
-
630
570
@ cython.wraparound (False )
631
571
@ cython.boundscheck (False )
632
572
cdef _array_to_datetime_object(
0 commit comments