@@ -36,7 +36,7 @@ from cpython.datetime cimport (PyDelta_Check, PyTZInfo_Check,
36
36
# import datetime C API
37
37
PyDateTime_IMPORT
38
38
# this is our datetime.pxd
39
- from datetime cimport pandas_datetime_to_datetimestruct, _string_to_dts
39
+ from datetime cimport _string_to_dts
40
40
41
41
# stdlib datetime imports
42
42
from datetime import time as datetime_time
@@ -46,10 +46,9 @@ from tslibs.np_datetime cimport (check_dts_bounds,
46
46
reverse_ops,
47
47
cmp_scalar,
48
48
pandas_datetimestruct,
49
- PANDAS_DATETIMEUNIT, PANDAS_FR_ns,
50
49
dt64_to_dtstruct, dtstruct_to_dt64,
51
50
pydatetime_to_dt64, pydate_to_dt64,
52
- get_datetime64_unit, get_datetime64_value,
51
+ get_datetime64_value,
53
52
get_timedelta64_value,
54
53
days_per_month_table,
55
54
dayofweek, is_leapyear)
@@ -1244,43 +1243,6 @@ cpdef inline object _localize_pydatetime(object dt, object tz):
1244
1243
return dt.replace(tzinfo = tz)
1245
1244
1246
1245
1247
- def datetime_to_datetime64 (ndarray[object] values ):
1248
- cdef:
1249
- Py_ssize_t i, n = len (values)
1250
- object val, inferred_tz = None
1251
- ndarray[int64_t] iresult
1252
- pandas_datetimestruct dts
1253
- _TSObject _ts
1254
-
1255
- result = np.empty(n, dtype = ' M8[ns]' )
1256
- iresult = result.view(' i8' )
1257
- for i in range (n):
1258
- val = values[i]
1259
- if _checknull_with_nat(val):
1260
- iresult[i] = NPY_NAT
1261
- elif PyDateTime_Check(val):
1262
- if val.tzinfo is not None :
1263
- if inferred_tz is not None :
1264
- if get_timezone(val.tzinfo) != inferred_tz:
1265
- raise ValueError (' Array must be all same time zone' )
1266
- else :
1267
- inferred_tz = get_timezone(val.tzinfo)
1268
-
1269
- _ts = convert_datetime_to_tsobject(val, None )
1270
- iresult[i] = _ts.value
1271
- check_dts_bounds(& _ts.dts)
1272
- else :
1273
- if inferred_tz is not None :
1274
- raise ValueError (' Cannot mix tz-aware with '
1275
- ' tz-naive values' )
1276
- iresult[i] = pydatetime_to_dt64(val, & dts)
1277
- check_dts_bounds(& dts)
1278
- else :
1279
- raise TypeError (' Unrecognized value type: %s ' % type (val))
1280
-
1281
- return result, inferred_tz
1282
-
1283
-
1284
1246
def format_array_from_datetime (ndarray[int64_t] values , object tz = None ,
1285
1247
object format = None , object na_rep = None ):
1286
1248
"""
@@ -1760,50 +1722,6 @@ cpdef array_to_datetime(ndarray[object] values, errors='raise',
1760
1722
return oresult
1761
1723
1762
1724
1763
- # ----------------------------------------------------------------------
1764
- # Conversion routines
1765
-
1766
- def cast_to_nanoseconds (ndarray arr ):
1767
- cdef:
1768
- Py_ssize_t i, n = arr.size
1769
- ndarray[int64_t] ivalues, iresult
1770
- PANDAS_DATETIMEUNIT unit
1771
- pandas_datetimestruct dts
1772
-
1773
- shape = (< object > arr).shape
1774
-
1775
- ivalues = arr.view(np.int64).ravel()
1776
-
1777
- result = np.empty(shape, dtype = ' M8[ns]' )
1778
- iresult = result.ravel().view(np.int64)
1779
-
1780
- if len (iresult) == 0 :
1781
- return result
1782
-
1783
- unit = get_datetime64_unit(arr.flat[0 ])
1784
- for i in range (n):
1785
- if ivalues[i] != NPY_NAT:
1786
- pandas_datetime_to_datetimestruct(ivalues[i], unit, & dts)
1787
- iresult[i] = dtstruct_to_dt64(& dts)
1788
- check_dts_bounds(& dts)
1789
- else :
1790
- iresult[i] = NPY_NAT
1791
-
1792
- return result
1793
-
1794
-
1795
- cdef inline _to_i8(object val):
1796
- cdef pandas_datetimestruct dts
1797
- try :
1798
- return val.value
1799
- except AttributeError :
1800
- if is_datetime64_object(val):
1801
- return get_datetime64_value(val)
1802
- elif PyDateTime_Check(val):
1803
- return Timestamp(val).value
1804
- return val
1805
-
1806
-
1807
1725
# ----------------------------------------------------------------------
1808
1726
# Accessors
1809
1727
0 commit comments