Thanks to visit codestin.com
Credit goes to github.com

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
2 changes: 1 addition & 1 deletion doc/source/release.rst
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,6 @@ Bug Fixes
as regexs even when ``regex=False`` (:issue:`6777`).
- Bug in timedelta ops on 32-bit platforms (:issue:`6808`)
- Bug in setting a tz-aware index directly via ``.index`` (:issue:`6785`)
<<<<<<< HEAD
- Bug in expressions.py where numexpr would try to evaluate arithmetic ops
(:issue:`6762`).
- Bug in Makefile where it didn't remove Cython generated C files with ``make
Expand All @@ -324,6 +323,7 @@ Bug Fixes
- Bug in ``DataFrame._reduce`` where non bool-like (0/1) integers were being
coverted into bools. (:issue:`6806`)
- Regression from 0.13 with ``fillna`` and a Series on datetime-like (:issue:`6344`)
- Bug in adding np.timedelta64 to DatetimeIndex with tz outputs incorrect result (:issue:`6818`)

pandas 0.13.1
-------------
Expand Down
12 changes: 5 additions & 7 deletions pandas/tseries/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -624,17 +624,15 @@ def _add_delta(self, delta):
if isinstance(delta, (Tick, timedelta)):
inc = offsets._delta_to_nanoseconds(delta)
new_values = (self.asi8 + inc).view(_NS_DTYPE)
tz = 'UTC' if self.tz is not None else None
result = DatetimeIndex(new_values, tz=tz, freq='infer')
utc = _utc()
if self.tz is not None and self.tz is not utc:
result = result.tz_convert(self.tz)
elif isinstance(delta, np.timedelta64):
new_values = self.to_series() + delta
result = DatetimeIndex(new_values, tz=self.tz, freq='infer')
else:
new_values = self.astype('O') + delta
result = DatetimeIndex(new_values, tz=self.tz, freq='infer')
tz = 'UTC' if self.tz is not None else None
result = DatetimeIndex(new_values, tz=tz, freq='infer')
utc = _utc()
if self.tz is not None and self.tz is not utc:
result = result.tz_convert(self.tz)
return result

def __contains__(self, key):
Expand Down
16 changes: 16 additions & 0 deletions pandas/tseries/tests/test_timezones.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from pandas.core.datetools import BDay
import pandas.core.common as com

from pandas import _np_version_under1p7

def _skip_if_no_pytz():
try:
Expand Down Expand Up @@ -961,6 +962,21 @@ def test_tzaware_offset(self):
offset = dates + offsets.Hour(5)
self.assertEqual(dates[0] + offsets.Hour(5), offset[0])

# GH 6818
for tz in ['UTC', 'US/Pacific', 'Asia/Tokyo']:
dates = date_range('2010-11-01 00:00', periods=3, tz=tz, freq='H')
expected = DatetimeIndex(['2010-11-01 05:00', '2010-11-01 06:00',
'2010-11-01 07:00'], freq='H', tz=tz)

offset = dates + offsets.Hour(5)
self.assert_(offset.equals(expected))
if not _np_version_under1p7:
offset = dates + np.timedelta64(5, 'h')
self.assert_(offset.equals(expected))
offset = dates + timedelta(hours=5)
self.assert_(offset.equals(expected))


if __name__ == '__main__':
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'],
exit=False)