-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Fix DTI comparison with None, datetime.date #19301
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
Changes from 1 commit
b100f59
59ac32c
79d9a02
6720de9
c2c1da5
69f527d
f2dbb7e
0184b39
5dcc09c
78d4eb1
39ad04d
d578aba
6ba5d99
578a4a3
b57d15d
0e0886a
2ea1205
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,7 +47,7 @@ class TestDatetimeIndexComparisons(object): | |
@pytest.mark.parametrize('other', [None, | ||
datetime(2016, 1, 1).date(), | ||
np.nan]) | ||
def test_dti_cmp_invalid(self, tz, other): | ||
def test_dti_cmp_non_datetime(self, tz, other): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. dti_cmp_null_scalar There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure |
||
# GH#19301 | ||
dti = pd.date_range('2016-01-01', periods=2, tz=tz) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So is this saying that DatetimeIndex([None, '2016-01-01']) == [None, datetime.date(2016, 1, 1)]) is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @TomAugspurger I think part of the confusion is over Following this, #19288 can be de-kludged to make For the moment I'm taking
I recall a discussion of whether There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I find [5] a bit odd. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The behavior is analogous to comparing |
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add
pd.NaT
hereThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, pd.NaT behaves differently from None or np.nan.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
huh? that would be troubling, why is that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
__eq__
and__ne__
behave the same, but None and np.nan raiseTypeError
for the inequalities, whereas pd.NaT returns False.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right. ok then split the tests to reflect this, testing all nulls at once for eq/ne make the test easy to grok.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll do this, but object to the notions that fixtures and easy-to-grok can go in the same file. If I can't import the test and run it in the interpreter, then I'm in a Strange Land.