i have a 1000 * 1000 numpy array with 1 million values which was created as follows :
>>import numpy as np >>data = np.loadtxt(\'space_data.txt\
import numpy as np data = np.array([[ 13., 15., 15.], [ 14., 13., 14. ], [ 16., 13., 13. ]]) key = [[ 10., 'S'], [ 11., 'S'], [ 12., 'S'], [ 13., 'M'], [ 14., 'L'], [ 15., 'S'], [ 16., 'S']] data2 = np.zeros(data.shape, dtype=str) for k in key: data2[data == k[0]] = k[1]