File tree 2 files changed +7
-7
lines changed
2 files changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ from cpython.object cimport PyObject
12
12
import_datetime()
13
13
14
14
15
+ import dateutil
15
16
cimport numpy as cnp
16
17
from numpy cimport (
17
18
float64_t,
@@ -42,7 +43,6 @@ from pandas._libs.util cimport (
42
43
is_float_object,
43
44
is_integer_object,
44
45
)
45
- import datetime as dt
46
46
47
47
from pandas._libs.tslibs.np_datetime import OutOfBoundsDatetime
48
48
from pandas._libs.tslibs.parsing import parse_datetime_string
@@ -723,12 +723,12 @@ cpdef array_to_datetime(
723
723
if not is_same_offsets:
724
724
_result = np.empty(n, dtype = " object" )
725
725
for i in range (n):
726
- if iresult[i] ! = iresult[i] or iresult[i] == NPY_NAT:
727
- _result[i] = result[i]
726
+ if iresult[i] == NPY_NAT:
727
+ _result[i] = NaT
728
728
continue
729
- _dt = dt.datetime.utcfromtimestamp(iresult [i]/ 1 _000_000_000 )
729
+ _dt = parse_datetime_string( str (result [i]) )
730
730
if result_timezone[i] is not None :
731
- _tzinfo = pytz.FixedOffset( result_timezone[i]/ 60 )
731
+ _tzinfo = dateutil.tz.tzoffset( None , result_timezone[i])
732
732
_result[i] = _dt.replace(tzinfo = pytz.UTC).astimezone(_tzinfo)
733
733
else :
734
734
_result[i] = _dt
Original file line number Diff line number Diff line change @@ -1353,11 +1353,11 @@ def test_mixed_offsets_with_native_datetime_raises(self):
1353
1353
mixed = to_datetime (ser )
1354
1354
expected = Series (
1355
1355
[
1356
- " NaT" ,
1356
+ NaT ,
1357
1357
Timestamp ("1990-01-01" ),
1358
1358
Timestamp ("2015-03-14T16:15:14.123-08:00" ).to_pydatetime (),
1359
1359
Timestamp ("2019-03-04T21:56:32.620-07:00" ).to_pydatetime (),
1360
- None ,
1360
+ NaT ,
1361
1361
],
1362
1362
dtype = object ,
1363
1363
)
You can’t perform that action at this time.
0 commit comments