Friday, March 10, 2017

QuickTip: Sorting Pairs of Numpy Arrays

Consider the two "connected" numpy arrays:

import numpy as np
x = np.array([1992,1991,1993])
y = np.array([15, 20, 30])

order = x.argsort()
x     = x[order]
y     = y[order]

x = array([1991, 1992, 1993])
y = array([20, 15, 30])

No comments:

Post a Comment