-
-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
implement+test mean for datetimelike EA/Index/Series #24757
Conversation
we are still treating datetimes as non-numeric yes? meaning that by default they will be exlcuded from say .mean() and you have to pass |
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 you see if we have coverage of this on mixed dtype frames as well? (see my comment about numeric_only). Also need to assert that other ops automatically exclude (e.g. std).
Codecov Report
@@ Coverage Diff @@
## master #24757 +/- ##
==========================================
+ Coverage 92.38% 92.38% +<.01%
==========================================
Files 166 166
Lines 52363 52378 +15
==========================================
+ Hits 48376 48391 +15
Misses 3987 3987
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #24757 +/- ##
==========================================
- Coverage 91.88% 91.87% -0.01%
==========================================
Files 174 174
Lines 50692 50708 +16
==========================================
+ Hits 46576 46588 +12
- Misses 4116 4120 +4
Continue to review full report at Codecov.
|
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.
need the tests from the OP (e.g. a mixed DataFrame)
I think that makes the most sense. |
Does this close #24752? |
I don't think so, will need to double-check. |
No, no it does not. |
@@ -47,6 +47,27 @@ def test_ops_properties_basic(self): | |||
assert s.day == 10 | |||
pytest.raises(AttributeError, lambda: s.weekday) | |||
|
|||
# TODO: figure out where in tests.reductions this belongs | |||
def test_mean(self, tz_naive_fixture): |
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.
seems very duplicative of the test below, is there a reason?
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.
bc at the time when this was written Index reduction tests had not been collected in tests.reductions. Will move/de-duplicate.
Eyeballing it at about 2012-03-14. Why would that be nonsensical? |
it’s no longer a M freq Period. my point is the mean if a span is an odd thing |
@jbrockmendel instead of keeping rebasing this, can you actually answer to my request for changes? (unless it is just lack of time that you didn't make any changes yet, that's no problem) |
can you merge master and fix the conflicts. @jorisvandenbossche this has been outstanding a while, any remaining issues? |
@jbrockmendel also pls respond to open questions from @jorisvandenbossche |
pandas/core/arrays/datetimelike.py
Outdated
@@ -1435,6 +1435,50 @@ def max(self, axis=None, skipna=True, *args, **kwargs): | |||
# Don't have to worry about NA `result`, since no NA went in. | |||
return self._box_func(result) | |||
|
|||
def mean(self, axis=None, skipna=True): |
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.
don'e we also need out=? meaning we should just accept kwargs like we do for Series.mean
pandas/core/arrays/datetimelike.py
Outdated
Parameters | ||
---------- | ||
axis : None | ||
Dummy parameter to match NumPy signature |
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.
would just add kwargs for this purpose; we don't add them explicity anywhere else
can you merge master; this looks fine otherwise, though I think @jorisvandenbossche had a question. |
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 seems good for now. There's still an outstanding discussion about accepting additional arguments so that methods like np.mean
work correctly. These are
- axis
- dtype
- out
- keepdims (optional)
but I'm fine with leaving that as a followup when someone wants it.
Given the lack of response of @jbrockmendel, I added a commit that removes the Fine with merging it like this. |
ok, pls merge on green. @jorisvandenbossche I guess worthwile to create a followup issue. |
My bad. Starting next month I'm working FT on pandas, so until then I'm focusing on statsmodels and spending time outdoors. Will rebase momentarily. |
I think this will pass if you merge master? |
Enjoy your time off! Failures were actually real ones: pushed fixes for a problem with the axis (that I caused) and a docstring lint error |
@jbrockmendel one more merge master pls. |
gentle ping |
thanks @jbrockmendel |
This takes over from #23890, implementing+testing reductions one at a time.
git diff upstream/master -u -- "*.py" | flake8 --diff