Bill Baxter wrote: >> In [35]: x = [ 0, 0, 0, 99, 0, 1, 5] >> In [37]: i=nonzero(x) >> In [38]: i >> Out[38]: (array([3, 5, 6]),)
> Just do i[0]. It's an array, not a string. Try typing "type(i[0])" > and see what it tells you. Which still begs the question: why does nonzero() return a tuple with an array in it, rather than just the array? Is it so you can so this? >>> a = numpy.array(((3,0,4),(5,21,0))) >>> numpy.nonzero(a) (array([0, 0, 1, 1]), array([0, 2, 0, 1])) >>> a[numpy.nonzero(a)] array([ 3, 4, 5, 21]) -Chris -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception [EMAIL PROTECTED] _______________________________________________ Numpy-discussion mailing list [email protected] http://projects.scipy.org/mailman/listinfo/numpy-discussion
