-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
GroupBy like API for resample #1269
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
Comments
Let me dig into this a bit right now. My analysis project for this afternoon was already going to require digging into pandas' resampling in more depth anyways. |
Assuming we want to stick with ds.resample(time='24H').mean('time') or else |
Would be great to test for these sorts of issues if we redo this: #1269 |
I think an interface like |
@MaximilianR Oh, the interface is easy enough to do, even maintaining backwards-compatibility (already have that working). I was considering going the route done with GroupBy and the classes that compose it, like DatasetGroupBy... basically, we just record the wanted resampling dimension and inject the grouping/resampling operations we want. Also adds the ability to specialize methods like But.... if there's a simpler way, that might be preferable! |
I think this could be done with minimal GroupBy subclasses to supply the
default dimension argument for aggregation functions. All the machinery on
groupby should already be there.
…On Wed, Feb 15, 2017 at 10:59 AM Daniel Rothenberg ***@***.***> wrote:
@MaximilianR <https://github.com/MaximilianR> Oh, the interface is easy
enough to do, even maintaining backwards-compatibility (already have that
working). I was considering going the route done with GroupBy
<https://github.com/pydata/xarray/blob/93d6963315026f87841c7cf39cc39bb78f555345/xarray/core/groupby.py#L165>
and the classes that compose it, like DatasetGroupBy
<https://github.com/pydata/xarray/blob/93d6963315026f87841c7cf39cc39bb78f555345/xarray/core/groupby.py#L586>...
basically, we just record the wanted resampling dimension and inject the
grouping/resampling operations we want. Also adds the ability to specialize
methods like .first() and .last(), which is done under the current
implementation.
*But*.... if there's a simpler way, that might be preferable!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1269 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ABKS1mAUBUkz7ig3fijFmqg6IeDnGgdeks5rc0sJgaJpZM4MAyE5>
.
|
Since we wrote
resample
in xarray, pandas updated resample to have a groupyby-like API (e.g.,df.resample('24H').mean()
vs. the olddf.resample('24H')
that uses the mean by default).It would be nice to redo the xarray resample API to match, e.g.,
ds.resample(time='24H').mean()
vsds.resample('time', '24H')
. This would solve a few use cases, including grouped-resample arithmetic, iterating over groups and (mostly) take care of the need forpd.TimeGrouper
support (#364). If we use**kwargs
for matching dimension names, this could be done with a minimally painful deprecation cycle.The text was updated successfully, but these errors were encountered: