[Numpy-discussion] add axis to results of reduction (mean, min, ...)
Thu Aug 6 12:07:13 CDT 2009
On Thu, Aug 6, 2009 at 9:58 AM, Charles R
> On Thu, Aug 6, 2009 at 9:55 AM, <firstname.lastname@example.org> wrote:
>> What's the best way of getting back the correct shape to be able to
>> broadcast, mean, min,.. to the original array, that works for
>> arbitrary dimension and axis?
>> I thought I have seen some helper functions, but I don't find them
> Adding a keyword to retain the number of dimensions has been mooted. It
> shouldn't be too difficult to implement and would allow things like:
>>>> scaled = a/a.max(1, reduce=0)
> I could do that for 1.4 if folks are interested.
I'd use that. It's better than what I usually do:
scaled = a / a.max(1).reshape(-1,1)
More information about the NumPy-Discussion