Skip to content

Commit 4233c0f

Browse files
committed
Merge pull request #7375 from sinhrks/offsets
ENH/BUG: Offset.apply dont preserve time
2 parents 53c6b08 + 728b0a7 commit 4233c0f

File tree

4 files changed

+384
-120
lines changed

4 files changed

+384
-120
lines changed

doc/source/timeseries.rst

+19
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,25 @@ The ``rollforward`` and ``rollback`` methods do exactly what you would expect:
539539
It's definitely worth exploring the ``pandas.tseries.offsets`` module and the
540540
various docstrings for the classes.
541541

542+
These operations (``apply``, ``rollforward`` and ``rollback``) preserves time (hour, minute, etc) information by default. To reset time, use ``normalize=True`` keyword when create offset instance. If ``normalize=True``, result is normalized after the function is applied.
543+
544+
545+
.. ipython:: python
546+
547+
day = Day()
548+
day.apply(Timestamp('2014-01-01 09:00'))
549+
550+
day = Day(normalize=True)
551+
day.apply(Timestamp('2014-01-01 09:00'))
552+
553+
hour = Hour()
554+
hour.apply(Timestamp('2014-01-01 22:00'))
555+
556+
hour = Hour(normalize=True)
557+
hour.apply(Timestamp('2014-01-01 22:00'))
558+
hour.apply(Timestamp('2014-01-01 23:00'))
559+
560+
542561
Parametric offsets
543562
~~~~~~~~~~~~~~~~~~
544563

doc/source/v0.14.1.txt

+10
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,18 @@ API changes
3333

3434

3535

36+
- All ``offsets`` suppports ``normalize`` keyword to specify whether ``offsets.apply``, ``rollforward`` and ``rollback`` resets time (hour, minute, etc) or not (default ``False``, preserves time) (:issue:`7156`)
3637

3738

39+
.. ipython:: python
40+
41+
import pandas.tseries.offsets as offsets
42+
43+
day = offsets.Day()
44+
day.apply(Timestamp('2014-01-01 09:00'))
45+
46+
day = offsets.Day(normalize=True)
47+
day.apply(Timestamp('2014-01-01 09:00'))
3848

3949

4050

0 commit comments

Comments
 (0)