ENH: enhancements to Panel.apply to enable arbitrary functions and multi-dim slicing (GH1148) #5850
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
closes #1148
A reproduction of the new docs section
Applying with a Panel will pass a Series to the applied function. If the applied function returns a Series, the result of the application will be a Panel. If the applied function reduces to a scalar, the result of the application will be a DataFrame.
Note Prior to 0.13.1 apply on a Panel would only work on ufuncs (e.g. np.sum/np.max).
A transformational apply.
A reduction operation.
A similar reduction type operation
This last reduction is equivalent to
A transformation operation that returns a Panel, but is computing the z-score across the major_axis.
Apply can also accept multiple axes in the axis argument. This will pass a DataFrame of the cross-section to the applied function.
This is equivalent to the following