Skip to content

ENH: Apply numpy function to named axes #652

@max-sixty

Description

@max-sixty

I'm currently transitioning sequences of pandas Panels over to xray Datasets. Part of our process applies a set of functions to Panels; for example:

panel = panel.apply(lambda x: x.rank(ascending=False), axis=(1, 2))
df = np.nanpercentile(panel, q=75, axis=2)

One of the benefits of xray is the clarity that comes from named axes. Is there a way of applying a function over named axes?
For example:

result = data_array.apply(np.argsort, axis=('Risk', 'Dates'))
result = data_array.apply(np.nanpercentile, axis='Dates')

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions