Skip to content

Commit 6b01b7d

Browse files
committed
Fix+test timezone-preservation in DTA.repeat
1 parent 8dd9cdd commit 6b01b7d

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

pandas/core/arrays/datetimelike.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ def repeat(self, repeats, *args, **kwargs):
698698
"""
699699
nv.validate_repeat(args, kwargs)
700700
values = self._data.repeat(repeats)
701-
return type(self)(values, dtype=self.dtype)
701+
return type(self)._simple_new(values, dtype=self.dtype)
702702

703703
# ------------------------------------------------------------------
704704
# Null Handling

pandas/tests/arrays/test_datetimes.py

+7
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,10 @@ def test_setitem_clears_freq(self):
9090
tz='US/Central'))
9191
a[0] = pd.Timestamp("2000", tz="US/Central")
9292
assert a.freq is None
93+
94+
def test_repeat_preserves_tz(self):
95+
dti = pd.date_range('2000', periods=2, freq='D', tz='US/Central')
96+
arr = DatetimeArray(dti)
97+
98+
repeated = arr.repeat([1, 1])
99+
tm.assert_equal(arr, repeated)

0 commit comments

Comments
 (0)