Skip to content

Commit 87a1a9f

Browse files
mroeschkeYi Wei
authored and
Yi Wei
committed
BUG: Have non nano rounding noop return copy (pandas-dev#52982)
1 parent c89f929 commit 87a1a9f

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
@@ -2055,7 +2055,7 @@ def _round(self, freq, mode, ambiguous, nonexistent):
20552055
nanos = delta_to_nanoseconds(offset, self._creso)
20562056
if nanos == 0:
20572057
# GH 52761
2058-
return self
2058+
return self.copy()
20592059
result_i8 = round_nsint64(values, mode, nanos)
20602060
result = self._maybe_mask_results(result_i8, fill_value=iNaT)
20612061
result = result.view(self._ndarray.dtype)

pandas/tests/series/accessors/test_dt_accessor.py

+2
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,8 @@ def test_dt_round_nonnano_higher_resolution_no_op(self, freq):
396396
result = ser.dt.round(freq)
397397
tm.assert_series_equal(result, expected)
398398

399+
assert not np.shares_memory(ser.array._ndarray, result.array._ndarray)
400+
399401
def test_dt_namespace_accessor_categorical(self):
400402
# GH 19468
401403
dti = DatetimeIndex(["20171111", "20181212"]).repeat(2)

0 commit comments

Comments
 (0)