How can I make the following code faster? It takes an hour for a large NumPy array.
i = 0 for y in np.unique(y_in): y_in[y_in == y] = i i += 1
e.g. y_in contains any of these six values [0.1, 0.22, 0.27, 0.4, 0.51, 0.92] and I want to replace all 0.1 with 1, 0.22 with 2, etc.
https://stackoverflow.com/questions/66863561/replacing-numpy-array-values-finite-set-of-unique-values-with-a-list-of-new-va March 30, 2021 at 09:12AM
没有评论:
发表评论