Skip to content

Commit 9821a2e

Browse files
authored
REF: simplify Timestamp.replace (#47435)
1 parent 8dc832f commit 9821a2e

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

pandas/_libs/tslibs/timestamps.pyx

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ from pandas._libs.tslibs.nattype cimport (
8181
from pandas._libs.tslibs.np_datetime cimport (
8282
NPY_DATETIMEUNIT,
8383
NPY_FR_ns,
84-
check_dts_bounds,
8584
cmp_dtstructs,
8685
cmp_scalar,
8786
get_datetime64_unit,
@@ -2264,15 +2263,11 @@ default 'raise'
22642263
'fold': fold}
22652264
ts_input = datetime(**kwargs)
22662265

2267-
ts = convert_datetime_to_tsobject(ts_input, tzobj, nanos=0, reso=self._reso)
2268-
# TODO: passing nanos=dts.ps // 1000 causes a RecursionError in
2269-
# TestTimestampConstructors.test_constructor; not clear why
2270-
value = ts.value + (dts.ps // 1000)
2271-
if value != NPY_NAT:
2272-
check_dts_bounds(&dts, self._reso)
2273-
2266+
ts = convert_datetime_to_tsobject(
2267+
ts_input, tzobj, nanos=dts.ps // 1000, reso=self._reso
2268+
)
22742269
return create_timestamp_from_ts(
2275-
value, dts, tzobj, self._freq, fold, reso=self._reso
2270+
ts.value, dts, tzobj, self._freq, fold, reso=self._reso
22762271
)
22772272

22782273
def to_julian_date(self) -> np.float64:

0 commit comments

Comments
 (0)