diff --git a/pandas/_libs/tslibs/nattype.pyx b/pandas/_libs/tslibs/nattype.pyx index 3a61de62daf39..d5582d65a0c11 100644 --- a/pandas/_libs/tslibs/nattype.pyx +++ b/pandas/_libs/tslibs/nattype.pyx @@ -286,12 +286,6 @@ cdef class _NaT(datetime): def __hash__(self): return NPY_NAT - def __int__(self): - return NPY_NAT - - def __long__(self): - return NPY_NAT - @property def is_leap_year(self) -> bool: return False diff --git a/pandas/core/algorithms.py b/pandas/core/algorithms.py index ae7e8191fc482..3927fb04187f5 100644 --- a/pandas/core/algorithms.py +++ b/pandas/core/algorithms.py @@ -715,7 +715,7 @@ def factorize( values, dtype = _ensure_data(values) if original.dtype.kind in ["m", "M"]: - na_value = na_value_for_dtype(original.dtype) + na_value = iNaT else: na_value = None diff --git a/pandas/core/arrays/datetimelike.py b/pandas/core/arrays/datetimelike.py index 435da1ed062e6..1032559766ada 100644 --- a/pandas/core/arrays/datetimelike.py +++ b/pandas/core/arrays/datetimelike.py @@ -1607,7 +1607,7 @@ def _round(self, freq, mode, ambiguous, nonexistent): values = self.view("i8") result = round_nsint64(values, mode, freq) - result = self._maybe_mask_results(result, fill_value=NaT) + result = self._maybe_mask_results(result, fill_value=iNaT) return self._simple_new(result, dtype=self.dtype) @Appender((_round_doc + _round_example).format(op="round")) diff --git a/pandas/tests/arithmetic/test_timedelta64.py b/pandas/tests/arithmetic/test_timedelta64.py index 5f3d2040b0201..c4afe971d533e 100644 --- a/pandas/tests/arithmetic/test_timedelta64.py +++ b/pandas/tests/arithmetic/test_timedelta64.py @@ -679,7 +679,7 @@ def test_tdi_add_overflow(self): with pytest.raises(OutOfBoundsDatetime, match="10155196800000000000"): Timestamp("2000") + pd.to_timedelta(106580, "D") - _NaT = int(pd.NaT) + 1 + _NaT = pd.NaT.value + 1 msg = "Overflow in int64 addition" with pytest.raises(OverflowError, match=msg): pd.to_timedelta([106580], "D") + Timestamp("2000") diff --git a/pandas/tests/frame/methods/test_sort_values.py b/pandas/tests/frame/methods/test_sort_values.py index cd3286fa38056..86c9e2f5ffe52 100644 --- a/pandas/tests/frame/methods/test_sort_values.py +++ b/pandas/tests/frame/methods/test_sort_values.py @@ -323,7 +323,7 @@ def test_sort_values_nat_values_in_int_column(self): # cause was that the int64 value NaT was considered as "na". Which is # only correct for datetime64 columns. - int_values = (2, int(NaT)) + int_values = (2, int(NaT.value)) float_values = (2.0, -1.797693e308) df = DataFrame(