@@ -14,7 +14,7 @@ PyDateTime_IMPORT
14
14
15
15
16
16
cimport numpy as cnp
17
- from numpy cimport float64_t, int64_t, ndarray
17
+ from numpy cimport float64_t, int64_t, ndarray, uint8_t
18
18
import numpy as np
19
19
cnp.import_array()
20
20
@@ -351,7 +351,6 @@ def format_array_from_datetime(
351
351
352
352
def array_with_unit_to_datetime (
353
353
ndarray values ,
354
- ndarray mask ,
355
354
object unit ,
356
355
str errors = ' coerce'
357
356
):
@@ -373,8 +372,6 @@ def array_with_unit_to_datetime(
373
372
----------
374
373
values : ndarray of object
375
374
Date-like objects to convert.
376
- mask : boolean ndarray
377
- Not-a-time mask for non-nullable integer types conversion, can be None.
378
375
unit : object
379
376
Time unit to use during conversion.
380
377
errors : str, default 'raise'
@@ -395,6 +392,7 @@ def array_with_unit_to_datetime(
395
392
bint need_to_iterate = True
396
393
ndarray[int64_t] iresult
397
394
ndarray[object ] oresult
395
+ ndarray mask
398
396
object tz = None
399
397
400
398
assert is_ignore or is_coerce or is_raise
@@ -404,9 +402,6 @@ def array_with_unit_to_datetime(
404
402
result = values.astype(' M8[ns]' )
405
403
else :
406
404
result, tz = array_to_datetime(values.astype(object ), errors = errors)
407
- if mask is not None :
408
- iresult = result.view(' i8' )
409
- iresult[mask] = NPY_NAT
410
405
return result, tz
411
406
412
407
m = cast_from_unit(None , unit)
@@ -419,9 +414,8 @@ def array_with_unit_to_datetime(
419
414
if values.dtype.kind == " i" :
420
415
# Note: this condition makes the casting="same_kind" redundant
421
416
iresult = values.astype(' i8' , casting = ' same_kind' , copy = False )
422
- # If no mask, fill mask by comparing to NPY_NAT constant
423
- if mask is None :
424
- mask = iresult == NPY_NAT
417
+ # fill by comparing to NPY_NAT constant
418
+ mask = iresult == NPY_NAT
425
419
iresult[mask] = 0
426
420
fvalues = iresult.astype(' f8' ) * m
427
421
need_to_iterate = False
0 commit comments