@@ -376,7 +376,8 @@ cpdef array_to_datetime(
376376 bint dayfirst = False ,
377377 bint yearfirst = False ,
378378 bint utc = False ,
379- bint require_iso8601 = False
379+ bint require_iso8601 = False ,
380+ bint allow_mixed = False ,
380381):
381382 """
382383 Converts a 1D array of date-like values to a numpy array of either:
@@ -405,6 +406,8 @@ cpdef array_to_datetime(
405406 indicator whether the dates should be UTC
406407 require_iso8601 : bool, default False
407408 indicator whether the datetime string should be iso8601
409+ allow_mixed : bool, default False
410+ Whether to allow mixed datetimes and integers.
408411
409412 Returns
410413 -------
@@ -597,7 +600,7 @@ cpdef array_to_datetime(
597600 return ignore_errors_out_of_bounds_fallback(values), tz_out
598601
599602 except TypeError :
600- return array_to_datetime_object (values, errors, dayfirst, yearfirst)
603+ return _array_to_datetime_object (values, errors, dayfirst, yearfirst)
601604
602605 if seen_datetime and seen_integer:
603606 # we have mixed datetimes & integers
@@ -609,10 +612,12 @@ cpdef array_to_datetime(
609612 val = values[i]
610613 if is_integer_object(val) or is_float_object(val):
611614 result[i] = NPY_NAT
615+ elif allow_mixed:
616+ pass
612617 elif is_raise:
613618 raise ValueError (" mixed datetimes and integers in passed array" )
614619 else :
615- return array_to_datetime_object (values, errors, dayfirst, yearfirst)
620+ return _array_to_datetime_object (values, errors, dayfirst, yearfirst)
616621
617622 if seen_datetime_offset and not utc_convert:
618623 # GH#17697
@@ -623,7 +628,7 @@ cpdef array_to_datetime(
623628 # (with individual dateutil.tzoffsets) are returned
624629 is_same_offsets = len (out_tzoffset_vals) == 1
625630 if not is_same_offsets:
626- return array_to_datetime_object (values, errors, dayfirst, yearfirst)
631+ return _array_to_datetime_object (values, errors, dayfirst, yearfirst)
627632 else :
628633 tz_offset = out_tzoffset_vals.pop()
629634 tz_out = pytz.FixedOffset(tz_offset / 60. )
@@ -670,7 +675,7 @@ cdef ignore_errors_out_of_bounds_fallback(ndarray[object] values):
670675
671676@ cython.wraparound (False )
672677@ cython.boundscheck (False )
673- cdef array_to_datetime_object (
678+ cdef _array_to_datetime_object (
674679 ndarray[object ] values,
675680 str errors,
676681 bint dayfirst = False ,
0 commit comments