I have an one dimension numpy array with 1 to 5 numbers. I need to map these values to corresponding numbers between 0.76 to 1.24 with 0.12 interval.
Then the problem is the find exact values in one array and fill the exact index in the second array.
I did this using if,elif but I though there has to be a elegent way to do this.
def ClassConv(classNumVec): relativeMilk = np.empty([size]) for i in range(size): if classNumVec[i] == 1: relative[i] = 0.76 elif classNumVec[i] == 2: relative[i] = 0.88 elif classNumVec[i] == 3: relative[i] = 1 elif classNumVec[i] == 4: relative[i] = 1.12 else: relative[i] = 1.24 return relative
My searches resulted to numpy.where and biesct functions but could not do this.
Thanks in advance!