-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
ENH: GH3371 support timedelta fillna #4684
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
ENH: GH3371 support timedelta fillna
@cpcloud numpy 1.6.1 compat shall be conquered! (for timedelta)....what a mess they made :< |
@@ -705,6 +705,59 @@ def diff(arr, n, axis=0): | |||
return out_arr | |||
|
|||
|
|||
def _coerce_scalar_to_timedelta_type(r): |
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 is so insane 😄
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.
Just a suggestion - it might be easier to read if you separated the under 1.7 handling, like this: (I'm pretty sure this does the same thing as the current function). To me, this also makes it easier to see that under 1.7 it returns a timedelta and above 1.7 it returns a timedelta64 type.
def _coerce_scalar_to_timedelta_type(r):
# kludgy here until we have a timedelta scalar
# handle the numpy < 1.7 case
if is_integer(r):
r = timedelta(microseconds=r/1000)
if _np_version_under1p7:
if not isinstance(r, timedelta):
raise AssertionError("Invalid type for timedelta scalar: %s" % type(r))
return r
if isinstance(r, timedelta):
r = np.timedelta64(r)
elif not isinstance(r, np.timedelta64):
raise AssertionError("Invalid type for timedelta scalar: %s" % type(r))
return r.astype('timedelta64[ns]')
nope that should never even be user visible (the function or the exception) |
awesome - just wanted to check. You should add a |
return x | ||
|
||
if self.ndim == 1: | ||
if obj.dtype == 'm8[us]': |
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't you just slim this line and the next down to obj = f(obj)
? (otherwise, you're just repeating that type check twice)....
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.
yep could fix that up
@cpcloud that's crazy. |
API: exclude non-numerics if mixed types in _reduce operations BUG: timedelta fixes CLN: small cleaning in nanops.py BUG: allow _reduce to call .apply for certain operations when the who block fails via a reduce exception
finally got this to pass.....3.2 with 1.6 is of course different in its handing of timedeltas than 2.7 with 1.6....oh numpy |
ENH: GH3371 support timedelta fillna
closes #3371
ffill