-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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: add quantiles kw to Series.describe to create dynamic quantiles #4196
Comments
Assigned this to me, think it should be pretty straightforward (I don' think it even needs to be cythonized...) |
removed @hayd as assignee |
I've got an implementation for this. If you were to do In [7]: df = pd.DataFrame(np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]), columns=['a', 'b', 'c'])
In [8]: df
Out[8]:
a b c
0 1 2 3
1 4 5 6
2 7 8 9
[3 rows x 3 columns]
In [9]: df.quantile([.1, .9]) Would you expect Out[9]:
0.1 0.9
a 1.6 6.4
b 2.6 7.4
c 3.6 8.4
[3 rows x 2 columns] or Out[10]:
a b c
0.1 1.6 2.6 3.6
0.9 6.4 7.4 8.4
[2 rows x 3 columns] For comparison: In [11]: df.quantile(.1)
Out[11]:
a 1.6
b 2.6
c 3.6
dtype: float64 and In [13]: df['a'].quantile([.1, .9])
Out[13]:
0.1 1.6
0.9 6.4
dtype: float64 |
I think this one makes the most sense as you get back the same columns (of course they are just a transpose away)
|
👍 df['a'].quantile(..) should be the same as df.quantile(..)['a'](so I guess there should be some name attributes kicking around here). This would be nice addition! |
Thanks, that's what I was thinking. I've got one failing test, it may be a separate issue. In def _apply_empty_result(self, func, axis, reduce):
if reduce is None:
reduce = False
try:
reduce = not isinstance(func(_EMPTY_SERIES), Series) <---
except Exception:
pass
if reduce:
return Series(NA, index=self._get_agg_axis(axis))
else:
return self.copy() Should this function take the |
hmm...this is a heuristic to figure out if its a reduction function, so yes I think that would be right (take the args) |
I think do that fix as a separate PR |
This of course can be done directly, but adding the keyword
quantiles
that accepts a number or list (to create multiple fields), seems like a nice ideaand maybe deprecate
percentile_width
/ replace withquantiles=[50]
like this:
http://stackoverflow.com/questions/17578115/pass-percentiles-to-pandas-agg-function
The text was updated successfully, but these errors were encountered: