Skip to content

Commit 0d05306

Browse files
author
Matt Roeschke
committed
use is_null_datetimelike instead
1 parent b7aaa02 commit 0d05306

File tree

2 files changed

+2
-14
lines changed

2 files changed

+2
-14
lines changed

pandas/_libs/tslibs/nattype.pyx

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,6 @@ _nat_scalar_rules[Py_GE] = False
3939
# ----------------------------------------------------------------------
4040

4141

42-
cpdef bint is_np_nat(x):
43-
"""Compat check for np.datetime('NaT')"""
44-
try:
45-
return np.isnat(x)
46-
except AttributeError:
47-
# numpy 1.12 compat
48-
return str(x) == 'NaT'
49-
except (TypeError, ValueError):
50-
# np.isnat only defined for datetime, timedelta
51-
return False
52-
53-
5442
def _make_nan_func(func_name, doc):
5543
def f(*args, **kwargs):
5644
return np.nan

pandas/io/formats/format.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from pandas._libs import lib
1414
from pandas._libs.tslib import format_array_from_datetime
1515
from pandas._libs.tslibs import NaT, Timedelta, Timestamp, iNaT
16-
from pandas._libs.tslibs.nattype import is_np_nat
16+
from pandas._libs.tslibs.nattype import is_null_datetimelike
1717
from pandas.compat import StringIO, lzip, map, u, zip
1818

1919
from pandas.core.dtypes.common import (
@@ -947,7 +947,7 @@ def _format(x):
947947
if self.na_rep is not None and is_scalar(x) and isna(x):
948948
if x is None:
949949
return 'None'
950-
elif x is NaT or is_np_nat(x):
950+
elif x is NaT or is_null_datetimelike(x):
951951
return 'NaT'
952952
return self.na_rep
953953
elif isinstance(x, PandasObject):

0 commit comments

Comments
 (0)