@@ -955,35 +955,6 @@ cdef inline int month_to_quarter(int month) nogil:
955
955
# ----------------------------------------------------------------------
956
956
# Period logic
957
957
958
- @ cython.wraparound (False )
959
- @ cython.boundscheck (False )
960
- def dt64arr_to_periodarr (const int64_t[:] dtarr , int freq , tz = None ):
961
- """
962
- Convert array of datetime64 values (passed in as 'i8' dtype) to a set of
963
- periods corresponding to desired frequency, per period convention.
964
- """
965
- cdef:
966
- int64_t[:] out
967
- Py_ssize_t i, l
968
- npy_datetimestruct dts
969
-
970
- l = len (dtarr)
971
-
972
- out = np.empty(l, dtype = ' i8' )
973
-
974
- if tz is None :
975
- with nogil:
976
- for i in range (l):
977
- if dtarr[i] == NPY_NAT:
978
- out[i] = NPY_NAT
979
- continue
980
- dt64_to_dtstruct(dtarr[i], & dts)
981
- out[i] = get_period_ordinal(& dts, freq)
982
- else :
983
- out = localize_dt64arr_to_period(dtarr, freq, tz)
984
- return out.base # .base to access underlying np.ndarray
985
-
986
-
987
958
@ cython.wraparound (False )
988
959
@ cython.boundscheck (False )
989
960
def periodarr_to_dt64arr (const int64_t[:] periodarr , int freq ):
@@ -1473,8 +1444,7 @@ def extract_freq(ndarray[object] values):
1473
1444
1474
1445
@ cython.wraparound (False )
1475
1446
@ cython.boundscheck (False )
1476
- cdef int64_t[:] localize_dt64arr_to_period(const int64_t[:] stamps,
1477
- int freq, object tz):
1447
+ def dt64arr_to_periodarr (const int64_t[:] stamps , int freq , object tz ):
1478
1448
cdef:
1479
1449
Py_ssize_t n = len (stamps)
1480
1450
int64_t[:] result = np.empty(n, dtype = np.int64)
@@ -1523,7 +1493,7 @@ cdef int64_t[:] localize_dt64arr_to_period(const int64_t[:] stamps,
1523
1493
dt64_to_dtstruct(stamps[i] + deltas[pos[i]], & dts)
1524
1494
result[i] = get_period_ordinal(& dts, freq)
1525
1495
1526
- return result
1496
+ return result.base # .base to get underlying ndarray
1527
1497
1528
1498
1529
1499
DIFFERENT_FREQ = (" Input has different freq={other_freq} "
0 commit comments