-
-
Notifications
You must be signed in to change notification settings - Fork 19.4k
implement+test mean for datetimelike EA/Index/Series #24757
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
Changes from 36 commits
434e2cd
c8abf33
30eeb64
d48e2ef
0e32be2
231458d
1129e8c
38f829a
aba90ec
176b355
ccb790b
4f4cb6d
ec83db1
5fb1db9
028c789
50e714e
1b24e7d
4d40906
a49da37
94d3466
e4e6a03
7953a7b
15307da
da719e1
637b415
58bca36
abcb87a
4df0b1c
c9736d7
d2f5e6f
de9025c
4c553a9
330fc41
7c6201b
642d4e2
7b9fd42
4be012f
5682b65
581ff1a
34a83a4
14150ee
450c8ce
3e31ca1
111c345
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -1437,6 +1437,54 @@ 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): | ||||||
jreback marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| """ | ||||||
| Return the mean value of the Array or mean along an axis. | ||||||
|
|
||||||
| .. versionadded:: 0.25.0 | ||||||
|
|
||||||
jorisvandenbossche marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| Parameters | ||||||
| ---------- | ||||||
| axis : None | ||||||
| Dummy parameter to match NumPy signature | ||||||
|
||||||
| skipna : bool, default True | ||||||
| Whether to ignore any NaT elements | ||||||
|
|
||||||
TomAugspurger marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| See Also | ||||||
| -------- | ||||||
| numpy.ndarray.mean | ||||||
| Series.mean : Return the mean value in a Series. | ||||||
|
|
||||||
| Notes | ||||||
| ----- | ||||||
| mean is only defined for Datetime and Timedelta dtypes, not for Period. | ||||||
| """ | ||||||
| if is_period_dtype(self): | ||||||
| # See discussion in GH#24757 | ||||||
| raise TypeError( | ||||||
| "mean is not implemented for {cls} since the meaning may be " | ||||||
|
||||||
| "mean is not implemented for {cls} since the meaning may be " | |
| "mean is not implemented for {cls} since the meaning is " |
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.
The thing here is that it isn't ambiguous for Tick-frequencies, so "may be" is more accurate.
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.
What is the unambiguous result of the mean of this?
In [12]: idx = pd.period_range('2012-01-01', periods=4, freq='1s')
In [13]: idx
Out[13]:
PeriodIndex(['2012-01-01 00:00:00', '2012-01-01 00:00:01',
'2012-01-01 00:00:02', '2012-01-01 00:00:03'],
dtype='period[S]', freq='S')
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.
Period('2012-01-01 00:00:01', freq='S'). We already discussed rounding error in this thread.
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.
We mainly discussed that for datetime64, where I am fine with that.
But for Period, you implicitly used the start_times for taking the mean, while you could also have taken the end_times. So I still find this ambiguous.
(anyway, I think we agree to disallow it all-together for all Periods, so this is only about the error message)
Uh oh!
There was an error while loading. Please reload this page.