[SciPy-user] Again on Sorting Objects

Lorenzo Isella lorenzo.isella@gmail....
Tue Jan 22 15:18:19 CST 2008


I am glad the tread was judged interesting and I hope I did not ask 
questions whose answer had already been posted many times  (but my 
online searches were not successful).
Another closely related question:
You have the arrays

A=[1 12 2 3 12 7 9 9 7]
and
B=[5 8 99 12 1 3 7 4 2]

This is what I am after (A stands for some recorded events and I want to 
get rid of those which are too rare)
1)get rid of the elements of A which do not appear at least twice
A_new=[12 12 7 7 9 9]
2)get rid of the corresponding elements of B i.e.
B_new=[8 1 7 4]

are these also almost one-liners in Scipy/Numpy? I have to say I am 
impressed by how much one can achieve in a few lines.

Should these little cute tools appear somewhere in a cookbook?
Cheers

Lorenzo


More information about the SciPy-user mailing list