Thanks to visit codestin.com
Credit goes to github.com

Skip to content

np.isnan raises an error for datetime (NaT) #14831

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mathause opened this issue Nov 5, 2019 · 1 comment · Fixed by #14841
Closed

np.isnan raises an error for datetime (NaT) #14831

mathause opened this issue Nov 5, 2019 · 1 comment · Fixed by #14841

Comments

@mathause
Copy link

mathause commented Nov 5, 2019

Reproducing code example:

import numpy as np
a = np.array(['1999-12-15', 'NaT'], dtype='M8[ns]')

np.isnan(a)
np.nanmin(a)
np.nanmax(a)

Error message:

Each of those raises an:
TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

Background

Numpy 1.18 returns NaT for np.min(a) (it did skip NaT before 1.18; #14717). This breaks xarray (pydata/xarray#3409) and pandas (pandas-dev/pandas#29058) - therefore it would be good to make np.isnan work with datetime.

Also: #9009, #1307, #5222

Numpy/Python version information:

1.18.0.dev0+3b5db53 3.7.3 | packaged by conda-forge | (default, Jul 1 2019, 21:52:21)
[GCC 7.3.0]

@seberg
Copy link
Member

seberg commented Nov 18, 2019

Marked for 1.18. release, I guess probably Matti's PR is the practical thing to do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants