Skip to content

Commit af9117e

Browse files
author
Matt Roeschke
committed
Fix some bugs
1 parent 650ab15 commit af9117e

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

pandas/core/arrays/datetimes.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1236,9 +1236,11 @@ def _generate_regular_range(cls, start, end, periods, freq):
12361236
data = cls._simple_new(data.view(_NS_DTYPE), None, tz=tz)
12371237
else:
12381238
tz = None
1239-
# Start and end should have the same timestamp by this point
1239+
# start and end should have the same timezone by this point
12401240
if isinstance(start, Timestamp):
12411241
tz = start.tz
1242+
elif isinstance(end, Timestamp):
1243+
tz = end.tz
12421244

12431245
xdr = generate_range(start=start, end=end,
12441246
periods=periods, offset=freq)

pandas/tests/series/test_timezones.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ def test_getitem_pydatetime_tz(self, tzstr):
302302

303303
def test_series_truncate_datetimeindex_tz(self):
304304
# GH 9243
305-
idx = date_range('4/1/2005', '4/30/2005', freq='D', tz='US/Pacific')
305+
idx = date_range('4/1/2005', '4/30/2005', freq='CD', tz='US/Pacific')
306306
s = Series(range(len(idx)), index=idx)
307307
result = s.truncate(datetime(2005, 4, 2), datetime(2005, 4, 4))
308308
expected = Series([1, 2, 3], index=idx[1:4])

0 commit comments

Comments
 (0)