Skip to content

Commit ad5784b

Browse files
mroeschkemeeseeksmachine
authored andcommitted
Backport PR pandas-dev#52982: BUG: Have non nano rounding noop return copy
1 parent 8475f2f commit ad5784b

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

pandas/core/arrays/datetimelike.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2010,7 +2010,7 @@ def _round(self, freq, mode, ambiguous, nonexistent):
20102010
nanos = delta_to_nanoseconds(offset, self._creso)
20112011
if nanos == 0:
20122012
# GH 52761
2013-
return self
2013+
return self.copy()
20142014
result_i8 = round_nsint64(values, mode, nanos)
20152015
result = self._maybe_mask_results(result_i8, fill_value=iNaT)
20162016
result = result.view(self._ndarray.dtype)

pandas/tests/series/accessors/test_dt_accessor.py

+2
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,8 @@ def test_dt_round_nonnano_higher_resolution_no_op(self, freq):
392392
result = ser.dt.round(freq)
393393
tm.assert_series_equal(result, expected)
394394

395+
assert not np.shares_memory(ser.array._ndarray, result.array._ndarray)
396+
395397
def test_dt_namespace_accessor_categorical(self):
396398
# GH 19468
397399
dti = DatetimeIndex(["20171111", "20181212"]).repeat(2)

0 commit comments

Comments
 (0)