1
1
# -*- coding: utf-8 -*-
2
2
# cython: profile=False
3
3
4
- import warnings
5
-
6
4
cimport numpy as np
7
5
from numpy cimport (int8_t, int32_t, int64_t, import_array, ndarray,
8
- float64_t,
9
- NPY_INT64, NPY_DATETIME, NPY_TIMEDELTA)
6
+ float64_t, NPY_DATETIME, NPY_TIMEDELTA)
10
7
import numpy as np
11
8
12
9
import sys
@@ -16,12 +13,10 @@ from cpython cimport (
16
13
PyTypeObject,
17
14
PyFloat_Check,
18
15
PyComplex_Check,
19
- PyLong_Check,
20
16
PyObject_RichCompareBool,
21
17
PyObject_RichCompare,
22
18
Py_GT, Py_GE, Py_EQ, Py_NE, Py_LT, Py_LE,
23
- PyUnicode_Check,
24
- PyUnicode_AsUTF8String)
19
+ PyUnicode_Check)
25
20
26
21
cdef extern from " Python.h" :
27
22
cdef PyTypeObject * Py_TYPE(object )
@@ -38,7 +33,6 @@ from datetime cimport (
38
33
pandas_datetimestruct,
39
34
pandas_datetime_to_datetimestruct,
40
35
pandas_datetimestruct_to_datetime,
41
- cmp_pandas_datetimestruct,
42
36
days_per_month_table,
43
37
get_datetime64_value,
44
38
get_timedelta64_value,
@@ -68,23 +62,12 @@ from khash cimport (
68
62
kh_resize_int64, kh_get_int64)
69
63
70
64
from .tslibs.parsing import parse_datetime_string
71
- from .tslibs.parsing import DateParseError # noqa
72
65
73
66
cimport cython
74
67
75
- import re
76
68
import time
77
69
78
- # dateutil compat
79
- from dateutil.tz import (tzoffset, tzlocal as _dateutil_tzlocal,
80
- tzutc as _dateutil_tzutc,
81
- tzstr as _dateutil_tzstr)
82
-
83
- from dateutil.relativedelta import relativedelta
84
- from dateutil.parser import DEFAULTPARSER
85
-
86
- from pandas.compat import (parse_date, string_types, iteritems,
87
- StringIO, callable )
70
+ from pandas.compat import iteritems, callable
88
71
89
72
import operator
90
73
import collections
@@ -97,9 +80,6 @@ import_array()
97
80
# import datetime C API
98
81
PyDateTime_IMPORT
99
82
100
- # in numpy 1.7, will prob need the following:
101
- # numpy_pydatetime_import
102
-
103
83
cdef int64_t NPY_NAT = util.get_nat()
104
84
iNaT = NPY_NAT
105
85
@@ -318,7 +298,7 @@ class Timestamp(_Timestamp):
318
298
tz : string / timezone object, default None
319
299
Timezone to localize to
320
300
"""
321
- if isinstance (tz, string_types ):
301
+ if util.is_string_object (tz):
322
302
tz = maybe_get_tz(tz)
323
303
return cls (datetime.now(tz))
324
304
@@ -613,7 +593,7 @@ class Timestamp(_Timestamp):
613
593
if self .tzinfo is None :
614
594
# tz naive, localize
615
595
tz = maybe_get_tz(tz)
616
- if not isinstance (ambiguous, string_types ):
596
+ if not util.is_string_object (ambiguous):
617
597
ambiguous = [ambiguous]
618
598
value = tz_localize_to_utc(np.array([self .value], dtype = ' i8' ), tz,
619
599
ambiguous = ambiguous, errors = errors)[0 ]
@@ -2426,8 +2406,8 @@ class Timedelta(_Timedelta):
2426
2406
raise TypeError (
2427
2407
" Invalid type {0}. Must be int or float." .format(type (v)))
2428
2408
2429
- kwargs = dict ([ (k, _to_py_int_float(v))
2430
- for k, v in iteritems(kwargs) ])
2409
+ kwargs = dict ([(k, _to_py_int_float(v))
2410
+ for k, v in iteritems(kwargs)])
2431
2411
2432
2412
try :
2433
2413
nano = kwargs.pop(' nanoseconds' , 0 )
@@ -3682,7 +3662,7 @@ def tz_localize_to_utc(ndarray[int64_t] vals, object tz, object ambiguous=None,
3682
3662
result[i] = v - delta
3683
3663
return result
3684
3664
3685
- if isinstance (ambiguous, string_types ):
3665
+ if util.is_string_object (ambiguous):
3686
3666
if ambiguous == ' infer' :
3687
3667
infer_dst = True
3688
3668
elif ambiguous == ' NaT' :
0 commit comments