# numpy.isnat() method in python with examples

In this Python tutorial, we are going to learn about numpy.isnat() method. This method helps in figuring out whether the value returned by numpy.datetime64() and numpy.timedelta64() is a time or not. This function has a boolean return type and returns either True or False.

## numpy.isnat()

numpy.isnat() method takes one parameter and that should be the value returned by numpy.datetime64() or numpy.timedelta64() methods. Otherwise, it throws an error. The syntax for this function is given below:

numpy.isnat()

The function returns True if the values returned by above mentioned time functions is not a time, else it returns False. Here are some example programs that will explain the working of numpy.isnat() method.

**Example 1:**

Have a look at the code given below.

import numpy as np ret = np.isnat(np.datetime64("1999-09-09")) ret

Output:

False

As you can see in the output, the np.isnat() returns False because ‘1999-09-09’ is a time. Now, look at the next example and its output.

**Example 2:**

import numpy as np ret = np.isnat(np.datetime64("Nat")) ret

Output:

True

This time the np.isnat() method returns True, as the datetime64() method returns a value which is not a time.

**Example 3:**

In this example, we are going to use deltatime64() to pass as argument in the np.isnat() method. See the code and the output.

ret = np.isnat(np.timedelta64(15, 'D')) ret

Output:

False

**Example 4:**

ret = np.isnat(np.timedelta64("Nat")) ret

Output:

True

Thank you.

Also read: Python time sleep | Delay in execution of a program

## Leave a Reply