-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Series/Index results in datetime/timedelta incorrectly if inputs are all nan/nat like #13477
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
Conversation
Current coverage is 84.33%@@ master #13477 diff @@
==========================================
Files 138 138
Lines 51092 51092
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
Hits 43087 43087
Misses 8005 8005
Partials 0 0
|
@@ -1,5 +1,6 @@ | |||
import sys | |||
cimport util | |||
from tslib cimport is_timestamp |
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 think I might move this here as well (though may cause a circular import issue).
@sinhrks puzzled why this fixed things as all you did was move something |
ATM, it doesn't affect to the behavior. However, I found some inconsistency when I adding the test. Updated in #13467. |
32b86f9
to
03c016c
Compare
|
||
if util.is_datetime64_object(val) or val is NaT: | ||
# same logic as is_null_datetimelike except for integer nat |
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.
if its the same logic, then let's just add a flag that includes/excludes it rather then replicating the logic
(or make another function sitting below it that does 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.
ok as I commented on the other issue, I think all -> NaT/nan should be M8. |
@sinhrks ready to merge? or is there still an open question on this |
@jreback Updated based on #13467, and found that there is a test which expect How about skipping only
|
yeah that looks right the problem is we can't know definitively the inferred type if we only have pd.NaT (or just np.nan for that matter) so I suppose object is correct in those cases (though might break things) |
Yeah.
|
Updated based on the above discussion. |
e539f34
to
cd859a4
Compare
if is_datetime64_array(values): | ||
return 'datetime64' | ||
elif is_timedelta_or_timedelta64_array(values): | ||
return 'timedelta' | ||
|
||
elif util.is_integer_object(val): |
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.
hmm I thought this was needed maybe on py3? (the integer object check and then check for timedelta)
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.
Though test has been passed, will revert it for safety.
|
||
|
||
cdef inline bint is_null_datetime64(v): | ||
# determine if we have a null for a datetime (or integer versions)x, |
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.
do we need to export these (as in tslib.pxd)?
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.
Not needed ATM because tslib
doesn't use is_null_datetimelike
.
@sinhrks looks really good. esp all of the added tests! just a couple of very minor questions. ping when ready. |
tm.assert_series_equal(Series([pd.NaT, pd.NaT]), exp) | ||
tm.assert_series_equal(Series(np.array([pd.NaT, pd.NaT])), exp) | ||
|
||
exp = Series(pd.DatetimeIndex([pd.NaT, pd.NaT])) |
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.
What is the difference with the exp
above (exp = Series([pd.NaT, pd.NaT])
)?
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.
Not needed because of the bug fix. Removed.
Now all green. |
if is_datetime64_array(values): | ||
return 'datetime64' | ||
elif is_timedelta_or_timedelta64_array(values): | ||
return 'timedelta' | ||
|
||
elif is_timedelta(val): |
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.
This must be moved here. Otherwise, timedelta
and object
mixed data is regarded as "mixed-integer".
e6dc033
to
9dfda77
Compare
IIRC this was green. but rebase and ping. |
@jreback @jorisvandenbossche rebased, and all green. |
@sinhrks Thanks! |
git diff upstream/master | flake8 --diff