Skip to content

Commit ae2e6de

Browse files
committed
ENH: Timestamp pickle support non-nano tzaware (#47340)
1 parent e6ff89c commit ae2e6de

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

pandas/_libs/tslibs/timestamps.pyx

+1-8
Original file line numberDiff line numberDiff line change
@@ -157,14 +157,7 @@ cdef inline _Timestamp create_timestamp_from_ts(
157157

158158
def _unpickle_timestamp(value, freq, tz, reso=NPY_FR_ns):
159159
# GH#41949 dont warn on unpickle if we have a freq
160-
if reso == NPY_FR_ns:
161-
ts = Timestamp(value, tz=tz)
162-
else:
163-
if tz is not None:
164-
raise NotImplementedError
165-
abbrev = npy_unit_to_abbrev(reso)
166-
dt64 = np.datetime64(value, abbrev)
167-
ts = Timestamp._from_dt64(dt64)
160+
ts = Timestamp._from_value_and_reso(value, reso, tz)
168161
ts._set_freq(freq)
169162
return ts
170163

pandas/tests/scalar/timestamp/test_timestamp.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -842,7 +842,10 @@ def test_cmp_cross_reso_reversed_dt64(self):
842842

843843
assert other.asm8 < ts
844844

845-
def test_pickle(self, ts):
845+
def test_pickle(self, ts, tz_aware_fixture):
846+
tz = tz_aware_fixture
847+
tz = maybe_get_tz(tz)
848+
ts = Timestamp._from_value_and_reso(ts.value, ts._reso, tz)
846849
rt = tm.round_trip_pickle(ts)
847850
assert rt._reso == ts._reso
848851
assert rt == ts

0 commit comments

Comments
 (0)