Suppose I have something like myArray.shape == (100, 80, 2)
I want to do something like this:
numpy.apply_along_axis(function, 0, myArray)
where function
uses both items on the axis=2
axis of myArray, but I know numpy.apply_along_axis
only works for 1D slices.
My question is: Is there a generic way to go about acting a function to 2D slices without having to use a loop or does it depend on how I have function
defined? And if so, what would be the most efficient way of doing this?
Is it possible to use numpy.apply_along_axis
to act on one 1D slice and zip
each element in the other slice to each element in the first slice somehow? Would it help to restructure myArray
?
Note: This question did not answer my question, so please don't mark as duplicate.