Skip to content

Commit 662e427

Browse files
author
y-p
committed
ENH/BUG: add tz argument to to_timestamp of Period, GH2877
1 parent 7491a4f commit 662e427

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

doc/source/v0.11.0.txt

+2
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ Bug Fixes
315315
- Fixed slow printing of large Dataframes, due to inefficient dtype
316316
reporting (GH2807_)
317317
- Fix pretty-printing of infinite data structures (closes GH2978_)
318+
- Fixed exception when plotting timeseries bearing a timezone (closes GH2877_)
318319
- str.contains ignored na argument (GH2806_)
319320

320321
See the `full release notes
@@ -326,6 +327,7 @@ on GitHub for a complete list.
326327
.. _GH2837: https://github.com/pydata/pandas/issues/2837
327328
.. _GH2898: https://github.com/pydata/pandas/issues/2898
328329
.. _GH2978: https://github.com/pydata/pandas/issues/2978
330+
.. _GH2877: https://github.com/pydata/pandas/issues/2877
329331
.. _GH2739: https://github.com/pydata/pandas/issues/2739
330332
.. _GH2710: https://github.com/pydata/pandas/issues/2710
331333
.. _GH2806: https://github.com/pydata/pandas/issues/2806

pandas/tools/plotting.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1043,7 +1043,7 @@ def _no_base(self, freq):
10431043
if (base <= freqmod.FreqGroup.FR_DAY):
10441044
return x[:1].is_normalized
10451045

1046-
return Period(x[0], freq).to_timestamp() == x[0]
1046+
return Period(x[0], freq).to_timestamp(tz=x.tz) == x[0]
10471047
return True
10481048

10491049
def _use_dynamic_x(self):

pandas/tseries/period.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ def end_time(self):
188188
ordinal = (self + 1).start_time.value - 1
189189
return Timestamp(ordinal)
190190

191-
def to_timestamp(self, freq=None, how='start'):
191+
def to_timestamp(self, freq=None, how='start',tz=None):
192192
"""
193193
Return the Timestamp representation of the Period at the target
194194
frequency at the specified end (how) of the Period
@@ -216,7 +216,7 @@ def to_timestamp(self, freq=None, how='start'):
216216
val = self.asfreq(freq, how)
217217

218218
dt64 = tslib.period_ordinal_to_dt64(val.ordinal, base)
219-
return Timestamp(dt64)
219+
return Timestamp(dt64,tz=tz)
220220

221221
year = _period_field_accessor('year', 0)
222222
month = _period_field_accessor('month', 3)

0 commit comments

Comments
 (0)