-
-
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
Changes from 3 commits
2e8be51
3ed75f8
d532e7b
7e90fbd
b87d882
dcc4ee1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe 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 |
||
@pytest.mark.parametrize( | ||
"add", | ||
[ | ||
pd.Timedelta(0), | ||
pd.Timestamp.now(), | ||
pd.Timestamp.now("UTC"), | ||
pd.Timestamp.now("Asia/Tokyo"), | ||
], | ||
) | ||
def test_std(self, add): | ||
tdi = pd.TimedeltaIndex(["0H", "4H", "NaT", "4H", "0H", "2H"]) + add | ||
arr = tdi.array | ||
|
||
result = arr.std(skipna=True) | ||
|
@@ -303,18 +313,20 @@ def test_std(self): | |
assert isinstance(result, pd.Timedelta) | ||
assert result == expected | ||
|
||
result = nanops.nanstd(np.asarray(arr), skipna=True) | ||
assert isinstance(result, pd.Timedelta) | ||
assert result == expected | ||
if getattr(arr, "tz", None) is None: | ||
result = nanops.nanstd(np.asarray(arr), skipna=True) | ||
assert isinstance(result, pd.Timedelta) | ||
assert result == expected | ||
|
||
result = arr.std(skipna=False) | ||
assert result is pd.NaT | ||
|
||
result = tdi.std(skipna=False) | ||
assert result is pd.NaT | ||
|
||
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 commentThe 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 commentThe 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Yes, we have tests with explicit |
||
assert result is pd.NaT | ||
|
||
def test_median(self): | ||
tdi = pd.TimedeltaIndex(["0H", "3H", "NaT", "5H06m", "0H", "2H"]) | ||
|
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