[Numpy-discussion] trim_zeros in more than one dimension?

Charles R Harris charlesr.harris at gmail.com
Tue Apr 20 19:45:32 EDT 2010


On Tue, Apr 20, 2010 at 7:03 AM, Andreas Hilboll <lists at hilboll.de> wrote:

> Hi there,
>
> is there an easy way to do something like trim_zeros() does, but for a
> n-dimensional array? I have a 2d array with only zeros in the first and
> last rows and columns, and would like to trim this array to only the
> non-zero part ...
>
>
I think for your application it would be easier to use a subarray, something
like a[1:-1, 1:-1].

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20100420/f2d008ef/attachment.html>


More information about the NumPy-Discussion mailing list