I've got two numpy arrays lst and a and I want to sort the first column of a in the same order it appears in lst, while maintaining each row of a to have the same elements.
lst = np.array(['a','b','d','e','c'])
a = np.array([['e','b','a','d','c'],[1,2,3,4,5]]).T
My desired outcome is:
array([['a', '3'],
['b', '2'],
['d', '4'],
['e', '1'],
['c', '5']])
I can get this outcome via pandas:
(pd.DataFrame(lst, columns=['col'])
.merge(pd.DataFrame(a, columns=['col','data']), on='col')
.to_numpy())
but I was wondering if it's possible to do it only using numpy.