@@ -4,8 +4,8 @@ import warnings
44
55cimport numpy as np
66from numpy cimport (int8_t, int32_t, int64_t, import_array, ndarray,
7+ float64_t,
78 NPY_INT64, NPY_DATETIME, NPY_TIMEDELTA)
8- from datetime cimport get_datetime64_value, get_timedelta64_value
99import numpy as np
1010
1111import sys
@@ -30,20 +30,47 @@ cdef extern from "datetime_helper.h":
3030 double total_seconds(object )
3131
3232# this is our datetime.pxd
33- from datetime cimport cmp_pandas_datetimestruct
3433from libc.stdlib cimport free
3534
3635from util cimport (is_integer_object, is_float_object, is_datetime64_object,
3736 is_timedelta64_object, INT64_MAX)
3837cimport util
3938
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
4463from datetime import timedelta, datetime
4564from datetime import time as datetime_time
4665
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+
4774import re
4875
4976# dateutil compat
@@ -81,15 +108,6 @@ PyDateTime_IMPORT
81108cdef int64_t NPY_NAT = util.get_nat()
82109iNaT = NPY_NAT
83110
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-
93111
94112cdef inline object create_timestamp_from_ts(
95113 int64_t value, pandas_datetimestruct dts,
@@ -314,7 +332,7 @@ class Timestamp(_Timestamp):
314332 tz : string / timezone object, default None
315333 Timezone to localize to
316334 """
317- if isinstance (tz, basestring ):
335+ if isinstance (tz, string_types ):
318336 tz = maybe_get_tz(tz)
319337 return cls (datetime.now(tz))
320338
@@ -615,7 +633,7 @@ class Timestamp(_Timestamp):
615633 if self .tzinfo is None :
616634 # tz naive, localize
617635 tz = maybe_get_tz(tz)
618- if not isinstance (ambiguous, basestring ):
636+ if not isinstance (ambiguous, string_types ):
619637 ambiguous = [ambiguous]
620638 value = tz_localize_to_utc(np.array([self .value], dtype = ' i8' ), tz,
621639 ambiguous = ambiguous, errors = errors)[0 ]
0 commit comments