You can use loc and reshape:
s = pd.Series({0: 0.3, 6: 0.6, 9: 0.2, 11: 0.3, 14: 0.0, 17: 0.1, 23: 0.9})
a = np.array([[ 0, 0, 9, 11],
[ 6, 14, 6, 17]])
s.loc[a.flatten()].values.reshape(a.shape)
Out[192]:
array([[ 0.3, 0.3, 0.2, 0.3],
[ 0.6, 0. , 0.6, 0.1]])
Or:
pd.DataFrame(a).applymap(lambda x: s.loc[x]).values
Out[200]:
array([[ 0.3, 0.3, 0.2, 0.3],
[ 0.6, 0. , 0.6, 0.1]])
source
share