NumPy Logic functions: isnat() function
numpy.isnat() function
The isnat() function is used to test element-wise for NaT (not a time) and return result as a boolean array.
Syntax:
numpy.isnat(x, /, out=None, *, where=True, casting='same_kind', order='K',dtype=None, subok=True[, signature, extobj]) = <ufunc 'isnat'>
Version: 1.15.0
Parameter:
Name | Description | Required / Optional |
---|---|---|
x | Input array with datetime or timedelta data type. array_like |
Required |
out | A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs. ndarray, None, or tuple of ndarray and None |
Optional |
where | Values of True indicate to calculate the ufunc at that position, values of False indicate to leave the value in the output alone. array_like |
Optional |
**kwargs | For other keyword-only arguments | Required |
Returns:
y : ndarray or bool - True where x is NaT, false otherwise. This is a scalar if x is a scalar.
NumPy.isnat() method Example-1:
>>> import numpy as np
>>> np.isnat(np.datetime64("NaT"))
Output:
True
NumPy.isnat() method Example-2:
>>> import numpy as np
>>> np.isnat(np.datetime64("2017-01-01"))
Output:
False
NumPy.isnat() method Example-3:
>>> import numpy as np
>>> np.isnat(np.array(["NaT", "2017-01-01"], dtype="datetime64[ns]"))
Output:
array([ True, False])
Python - NumPy Code Editor:
Previous: isnan() function
Next: isneginf() function
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://w3resource.com/numpy/logic-functions/isnat.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics