Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 13921

Numpy use one array as mask for another array

$
0
0

I am trying to do these steps in NumPy. It was easy to do this with python list sort(), and argsort().

How do I do this in Numpy?

a = np.array([10,30,20,40,50])a_sorted = np.array([10,20,30,40,50])

Get mask of a_sorted

b = np.array(['one','three','two','four','five'])

Apply the mask to b

Expected array sorted according to a_sorted:

b_sorted = np.array(['one','two','three','four','five'])

Viewing all articles
Browse latest Browse all 13921

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>