Skip to content
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

BUG/API Should pd.NaT < "foo" raise? #35046

Closed
jbrockmendel opened this issue Jun 29, 2020 · 1 comment · Fixed by #35585
Closed

BUG/API Should pd.NaT < "foo" raise? #35046

jbrockmendel opened this issue Jun 29, 2020 · 1 comment · Fixed by #35585
Labels
Bug Datetime Datetime data dtype Error Reporting Incorrect or improved errors from pandas Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate
Milestone

Comments

@jbrockmendel
Copy link
Member

If we treat NaT as a datetime, we would expect pd.NaT == "foo" to return False, != to return True, and for the inequalities to raise:

>>> np.datetime64("NaT", "ns") < "foo"
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: '<' not supported between instances of 'numpy.ndarray' and 'str'

>>> np.nan < "foo"
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: '<' not supported between instances of 'float' and 'str'

>>> pd.NaT < "foo"
False

It isn't obvious to me that the existing behavior is intentional. If we change this to raise, we can simplify NaT.__richcmp__ a bit.

@jbrockmendel jbrockmendel added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Jun 29, 2020
@jreback
Copy link
Contributor

jreback commented Jun 29, 2020

yeah this looks suspect, should raise

@mroeschke mroeschke added Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Datetime Datetime data dtype and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Jun 29, 2020
@jreback jreback added this to the 1.2 milestone Aug 6, 2020
@jreback jreback added the Error Reporting Incorrect or improved errors from pandas label Aug 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Datetime Datetime data dtype Error Reporting Incorrect or improved errors from pandas Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants