@@ -4,8 +4,8 @@ import warnings
4
4
5
5
cimport numpy as np
6
6
from numpy cimport (int8_t, int32_t, int64_t, import_array, ndarray,
7
+ float64_t,
7
8
NPY_INT64, NPY_DATETIME, NPY_TIMEDELTA)
8
- from datetime cimport get_datetime64_value, get_timedelta64_value
9
9
import numpy as np
10
10
11
11
import sys
@@ -30,20 +30,47 @@ cdef extern from "datetime_helper.h":
30
30
double total_seconds(object )
31
31
32
32
# this is our datetime.pxd
33
- from datetime cimport cmp_pandas_datetimestruct
34
33
from libc.stdlib cimport free
35
34
36
35
from util cimport (is_integer_object, is_float_object, is_datetime64_object,
37
36
is_timedelta64_object, INT64_MAX)
38
37
cimport util
39
38
40
- from datetime cimport *
41
- from khash cimport *
42
- cimport cython
43
-
39
+ # this is our datetime.pxd
40
+ from datetime cimport (
41
+ pandas_datetimestruct,
42
+ pandas_datetime_to_datetimestruct,
43
+ pandas_datetimestruct_to_datetime,
44
+ cmp_pandas_datetimestruct,
45
+ days_per_month_table,
46
+ get_datetime64_value,
47
+ get_timedelta64_value,
48
+ get_datetime64_unit,
49
+ PANDAS_DATETIMEUNIT,
50
+ _string_to_dts,
51
+ _pydatetime_to_dts,
52
+ _date_to_datetime64,
53
+ npy_datetime,
54
+ is_leapyear,
55
+ dayofweek,
56
+ PANDAS_FR_ns,
57
+ PyDateTime_Check, PyDate_Check,
58
+ PyDateTime_IMPORT,
59
+ timedelta, datetime
60
+ )
61
+
62
+ # stdlib datetime imports
44
63
from datetime import timedelta, datetime
45
64
from datetime import time as datetime_time
46
65
66
+ from khash cimport (
67
+ khiter_t,
68
+ kh_destroy_int64, kh_put_int64,
69
+ kh_init_int64, kh_int64_t,
70
+ kh_resize_int64, kh_get_int64)
71
+
72
+ cimport cython
73
+
47
74
import re
48
75
49
76
# dateutil compat
@@ -81,15 +108,6 @@ PyDateTime_IMPORT
81
108
cdef int64_t NPY_NAT = util.get_nat()
82
109
iNaT = NPY_NAT
83
110
84
- # < numpy 1.7 compat for NaT
85
- compat_NaT = np.array([NPY_NAT]).astype(' m8[ns]' ).item()
86
-
87
-
88
- try :
89
- basestring
90
- except NameError : # py3
91
- basestring = str
92
-
93
111
94
112
cdef inline object create_timestamp_from_ts(
95
113
int64_t value, pandas_datetimestruct dts,
@@ -314,7 +332,7 @@ class Timestamp(_Timestamp):
314
332
tz : string / timezone object, default None
315
333
Timezone to localize to
316
334
"""
317
- if isinstance (tz, basestring ):
335
+ if isinstance (tz, string_types ):
318
336
tz = maybe_get_tz(tz)
319
337
return cls (datetime.now(tz))
320
338
@@ -615,7 +633,7 @@ class Timestamp(_Timestamp):
615
633
if self .tzinfo is None :
616
634
# tz naive, localize
617
635
tz = maybe_get_tz(tz)
618
- if not isinstance (ambiguous, basestring ):
636
+ if not isinstance (ambiguous, string_types ):
619
637
ambiguous = [ambiguous]
620
638
value = tz_localize_to_utc(np.array([self .value], dtype = ' i8' ), tz,
621
639
ambiguous = ambiguous, errors = errors)[0 ]
0 commit comments