-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
ENH: std for dt64 dtype #37436
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
ENH: std for dt64 dtype #37436
Conversation
@@ -785,6 +784,9 @@ def nanstd(values, axis=None, skipna=True, ddof=1, mask=None): | |||
>>> nanops.nanstd(s) | |||
1.0 | |||
""" | |||
if values.dtype == "M8[ns]": |
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.
shouldn't this be done in _get_values?
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 specific to std
@@ -290,8 +290,18 @@ def test_sum_2d_skipna_false(self): | |||
)._values | |||
tm.assert_timedelta_array_equal(result, expected) | |||
|
|||
def test_std(self): | |||
tdi = pd.TimedeltaIndex(["0H", "4H", "NaT", "4H", "0H", "2H"]) | |||
# Adding a Timestamp makes this a test for DatetimeArray.std |
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.
shouldn't this be in test_datetimes? yes i read your comment, but still the location is odd
result = nanops.nanstd(np.asarray(arr), skipna=False) | ||
assert result is pd.NaT | ||
if getattr(arr, "tz", None) is None: | ||
result = nanops.nanstd(np.asarray(arr), skipna=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.
are we sure the actual result is correct? e.g. you are just comparing vs the implementation itself. IOW a result which checks a fixed series of datetimes for mean/std would be good.
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.
agreed these tests needs fleshing out. im still giving thought to where they should live
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.
sure, that's fine about location. i am more concerned with if the results are actually correct; reasoning is that they are converted to i8 but need to make sure that these are coming back correct as well. i am not sure this is actually tested.
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.
Yes, we have tests with explicit expected
for std() with td64 in test_reductions, test_describe, and test_analytics.
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff