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\
# Create a dataframe out of your 'data' array and make a dictionary out of your 'key' array.
import numpy as np
import pandas as pd
data = np.array([[ 13., 15., 15.],
[ 14., 13., 14. ],
[ 16., 13., 13. ]])
data_df = pd.DataFrame(data)
key = dict({10 : 'S',11 : 'S', 12 : 'S', 13 : 'M',14:'L',15:'S',16:'S'})
# Replace the values in newly created dataframe and convert that into array.
data_df.replace(key,inplace = True)
data = np.array(data_df)
print(data)
This will be the output:
[['M' 'S' 'S']
['L' 'M' 'L']
['S' 'M' 'M']]