Skip to content

Commit 7e491a7

Browse files
committed
Fix some imports and move whatsnew
1 parent 25225bd commit 7e491a7

File tree

4 files changed

+38
-4
lines changed

4 files changed

+38
-4
lines changed

doc/source/whatsnew/v0.24.0.txt

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,39 @@ For situations where you need an ``ndarray`` of ``Interval`` objects, use
159159
np.asarray(idx)
160160
idx.values.astype(object)
161161

162+
.. _whatsnew_0240.api_breaking.period_end_time:
163+
164+
Time values in ``dt.end_time`` and ``to_timestamp(how='end')``
165+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
166+
167+
The time values in :class:`Period` and :class:`PeriodIndex` objects are now set
168+
to '23:59:59.999999999' when calling :attr:`Series.dt.end_time`, :attr:`Period.end_time`,
169+
:attr:`PeriodIndex.end_time`, :func:`Period.to_timestamp()` with ``how='end'``,
170+
or :func:`PeriodIndex.to_timestamp()` with ``how='end'`` (:issue:`17157`)
171+
172+
Previous Behavior:
173+
174+
.. code-block:: ipython
175+
176+
In [2]: p = pd.Period('2017-01-01', 'D')
177+
In [3]: pi = pd.PeriodIndex([p])
178+
179+
In [4]: pd.Series(pi).dt.end_time[0]
180+
Out[4]: Timestamp(2017-01-01 00:00:00)
181+
182+
In [5]: p.end_time
183+
Out[5]: Timestamp(2017-01-01 23:59:59.999999999)
184+
185+
Current Behavior:
186+
187+
.. ipython:: python
188+
189+
p = pd.Period('2017-01-01', 'D')
190+
pi = pd.PeriodIndex([p])
191+
192+
pd.Series(pi).dt.end_time[0]
193+
194+
p.end_time
162195

163196
.. _whatsnew_0240.api.datetimelike.normalize:
164197

pandas/_libs/tslibs/period.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22
# cython: profile=False
3-
from datetime import datetime, date, timedelta
3+
from datetime import datetime, date
44

55
from cpython cimport (
66
PyUnicode_Check,
@@ -34,7 +34,7 @@ cdef extern from "../src/datetime/np_datetime.h":
3434
cimport util
3535
from util cimport is_period_object, is_string_object, INT32_MIN
3636

37-
from pandas._libs.tslib import Timedelta
37+
from pandas._libs.tslibs.timedeltas import Timedelta
3838
from timestamps import Timestamp
3939
from timezones cimport is_utc, is_tzlocal, get_dst_info
4040
from timedeltas cimport delta_to_nanoseconds

pandas/core/indexes/datetimes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1749,7 +1749,7 @@ def _generate_regular_range(cls, start, end, periods, freq):
17491749
else:
17501750

17511751
xdr = generate_range(start=start, end=end,
1752-
periods=periods, offset=offset)
1752+
periods=periods, offset=freq)
17531753

17541754
dates = list(xdr)
17551755
# utc = len(dates) > 0 and dates[0].tzinfo is not None

pandas/core/indexes/period.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from pandas.core.tools.datetimes import parse_time_string
2626

2727
from pandas._libs.lib import infer_dtype
28-
from pandas._libs import tslib, index as libindex
28+
from pandas._libs import tslib, index as libindex, Timedelta
2929
from pandas._libs.tslibs.period import (Period, IncompatibleFrequency,
3030
DIFFERENT_FREQ_INDEX,
3131
_validate_end_alias)
@@ -507,6 +507,7 @@ def to_timestamp(self, freq=None, how='start'):
507507
end = how == 'E'
508508
if end:
509509
if freq == 'B':
510+
# roll forward to ensure we land on B date
510511
adjust = Timedelta(1, 'D') - Timedelta(1, 'ns')
511512
return self.to_timestamp(how='start') + adjust
512513
else:

0 commit comments

Comments
 (0)