Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions doc/source/v0.14.1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -244,12 +244,15 @@ Bug Fixes
- Bug in ``DatetimeIndex.to_period``, ``PeriodIndex.asobject``, ``PeriodIndex.to_timestamp`` doesn't preserve ``name`` (:issue:`7485`)
- Bug in ``DatetimeIndex.to_period`` and ``PeriodIndex.to_timestanp`` handle ``NaT`` incorrectly (:issue:`7228`)

- BUG in ``offsets.apply``, ''rollforward`` and ``rollback`` may return normal ``datetime`` (:issue:`7502`)


- BUG in ``resample`` raises ``ValueError`` when target contains ``NaT`` (:issue:`7227`)

- Bug in ``Timestamp.tz_localize`` resets ``nanosecond`` info (:issue:`7534`)



- Bug in ``Index.astype(float)`` where it would return an ``object`` dtype
``Index`` (:issue:`7464`).

Expand Down
9 changes: 3 additions & 6 deletions pandas/tseries/offsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def wrapper(self, other):
return tslib.NaT
if type(other) == date:
other = datetime(other.year, other.month, other.day)
elif isinstance(other, np.datetime64):
if isinstance(other, (np.datetime64, datetime)):
other = as_timestamp(other)

tz = getattr(other, 'tzinfo', None)
Expand All @@ -57,11 +57,8 @@ def wrapper(self, other):
if isinstance(other, Timestamp) and not isinstance(result, Timestamp):
result = as_timestamp(result)

if tz is not None:
if isinstance(result, Timestamp) and result.tzinfo is None:
result = result.tz_localize(tz)
elif isinstance(result, datetime) and result.tzinfo is None:
result = tz.localize(result)
if tz is not None and result.tzinfo is None:
result = result.tz_localize(tz)
return result
return wrapper

Expand Down
6 changes: 3 additions & 3 deletions pandas/tseries/tests/test_offsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def _check_offsetfunc_works(self, offset, funcname, dt, expected,
func = getattr(offset_s, funcname)

result = func(dt)
self.assert_(isinstance(result, datetime))
self.assert_(isinstance(result, Timestamp))
self.assertEqual(result, expected)

result = func(Timestamp(dt))
Expand All @@ -227,11 +227,11 @@ def _check_offsetfunc_works(self, offset, funcname, dt, expected,

dt_tz = pytz.timezone(tz).localize(dt)
result = func(dt_tz)
self.assert_(isinstance(result, datetime))
self.assert_(isinstance(result, Timestamp))
self.assertEqual(result, expected_localize)

result = func(Timestamp(dt, tz=tz))
self.assert_(isinstance(result, datetime))
self.assert_(isinstance(result, Timestamp))
self.assertEqual(result, expected_localize)

def _check_nanofunc_works(self, offset, funcname, dt, expected):
Expand Down