-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
CLN: use .view(i8) instead of .astype(i8) for datetimelike values #38535
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
CLN: use .view(i8) instead of .astype(i8) for datetimelike values #38535
Conversation
@@ -252,7 +253,9 @@ def __init__( | |||
raise ValueError( | |||
"halflife must be a string or datetime.timedelta object" | |||
) | |||
self.times = np.asarray(times.astype(np.int64)) | |||
if isna(times).any(): | |||
raise ValueError("Cannot convert NaT values to integer") |
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.
Could you add a test for this case?
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.
double-checked and you're right we dont have any. suggestions for what this might look like?
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.
Something simple like
with pytest.raises(ValueError, match=...):
Series(range(1)).ewm(com=0.1, times=to_datetime(['NaT'])))
works.
any perf benefits? |
maybe some call overhead, but the existing astype call is already doing view under the hood (which is not great) |
prelude to deprecating the astype behavior