Skip to content

Feature: Aggregate using one or more operations over the specified axis. #9479

Open
@kobebryant432

Description

@kobebryant432

Is your feature request related to a problem?

I'm always frustrated when I need to resample a ds and the resampling method is different for the variables present, i.e. for one variable I want the sum and for the other the mean.

Describe the solution you'd like

Ideally there would be some functionality similar to pandas .agg functionality.
Not sure if this is feasible.

ds = ds.resample(time="D").agg({"pr":"sum","tas":np.mean})

Describe alternatives you've considered

Current workaround which gets unwieldy for multiple variables.

ds_pr = ds.pr.resample(time="D").sum()
ds_tas = ds.tas.resample(time="D").mean()

ds = xr.merge([ds_pr, ds_tas])

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions