Skip to content

Commit 1910c7d

Browse files
committed
Apply diff
1 parent 3f1e594 commit 1910c7d

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

pandas/core/arrays/datetimes.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -329,13 +329,15 @@ def _simple_new(cls, values, freq=None, dtype=None):
329329
@classmethod
330330
def _from_sequence(cls, data, dtype=None, copy=False,
331331
tz=None, freq=None,
332-
dayfirst=False, yearfirst=False, ambiguous='raise'):
332+
dayfirst=False, yearfirst=False, ambiguous='raise',
333+
int_as_wall_time=False):
333334

334335
freq, freq_infer = dtl.maybe_infer_freq(freq)
335336

336337
subarr, tz, inferred_freq = sequence_to_dt64ns(
337338
data, dtype=dtype, copy=copy, tz=tz,
338-
dayfirst=dayfirst, yearfirst=yearfirst, ambiguous=ambiguous)
339+
dayfirst=dayfirst, yearfirst=yearfirst,
340+
ambiguous=ambiguous, int_as_wall_time=int_as_wall_time)
339341

340342
freq, freq_infer = dtl.validate_inferred_freq(freq, inferred_freq,
341343
freq_infer)
@@ -1634,9 +1636,11 @@ def to_julian_date(self):
16341636
# -------------------------------------------------------------------
16351637
# Constructor Helpers
16361638

1639+
16371640
def sequence_to_dt64ns(data, dtype=None, copy=False,
16381641
tz=None,
1639-
dayfirst=False, yearfirst=False, ambiguous='raise'):
1642+
dayfirst=False, yearfirst=False, ambiguous='raise',
1643+
int_as_wall_time=False):
16401644
"""
16411645
Parameters
16421646
----------
@@ -1662,7 +1666,6 @@ def sequence_to_dt64ns(data, dtype=None, copy=False,
16621666
------
16631667
TypeError : PeriodDType data is passed
16641668
"""
1665-
16661669
inferred_freq = None
16671670

16681671
dtype = _validate_dt64_dtype(dtype)
@@ -1733,6 +1736,12 @@ def sequence_to_dt64ns(data, dtype=None, copy=False,
17331736
# assume this data are epoch timestamps
17341737
if data.dtype != _INT64_DTYPE:
17351738
data = data.astype(np.int64, copy=False)
1739+
if int_as_wall_time and tz is not None:
1740+
warnings.warn("test", FutureWarning)
1741+
tz = timezones.maybe_get_tz(tz)
1742+
data = conversion.tz_localize_to_utc(data.view('i8'), tz,
1743+
ambiguous=ambiguous)
1744+
data = data.view(_NS_DTYPE)
17361745
result = data.view(_NS_DTYPE)
17371746

17381747
if copy:

pandas/core/indexes/datetimes.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,8 @@ def __new__(cls, data=None,
299299

300300
dtarr = DatetimeArray._from_sequence(
301301
data, dtype=dtype, copy=copy, tz=tz, freq=freq,
302-
dayfirst=dayfirst, yearfirst=yearfirst, ambiguous=ambiguous)
302+
dayfirst=dayfirst, yearfirst=yearfirst, ambiguous=ambiguous,
303+
int_as_wall_time=True)
303304

304305
subarr = cls._simple_new(dtarr, name=name,
305306
freq=dtarr.freq, tz=dtarr.tz)

0 commit comments

Comments
 (0)