[Numpy-discussion] Finding the same value in List
Wed Apr 17 04:32:26 CDT 2013
Greaaat thanks for your help.. By the way, the first one (I think) is much simpler.. I tested it and ,of course, it is 1D, but it is also a good idea to consider it for Ndimensional.
I prefer the first one! Do you you think first version is okay to use?
Среда, 17 апреля 2013, 11:02 +02:00 от Todd <email@example.com>:
>On Wed, Apr 17, 2013 at 10:46 AM, Todd < firstname.lastname@example.org > wrote:
>>f=[numpy.where(i==ind) for ind in range(len(x))]
>A better version would be (np.where returns tuples, but we don't want tuples):
>f=[numpy.where(i==ind) for ind in range(len(x))]
>You can also do it this way, but it is much harder to read IMO:
>This version figures out the indexes needed to put the values of y in sorted order (the same order x uses), then splits it into sub-arrays based on value. The principle is simpler but the implementation looks like clear to me.
>Note that these are only guaranteed to work on 1D arrays, I have not tested them on multidimensional arrays
>NumPy-Discussion mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion