jeudi 26 février 2015

populate values from one numpy array into another


Vote count:

0




I have some data in a numpy array, for example:



a = np.array([1,2,3,4,5,6,7,8,9,10])


I then want to subset some values from this array, i.e:



b = a[a > 5]


so that:



b = np.array([6,7,8,9,10])


I then conduct some simple calculations on this subset, i.e.:



c = b + 1


so that:



c = np.array([7,8,9,10,11])


I then want to repopulate the original array with the updated values, so that i end up with:



d = np.array([1,2,3,4,5,7,8,9,10,11])


My real data is obviously more involved than this so i would like to avoid doing it in one line just by indexing the values of interest from the original array (unless of course this is the easiest way of doing it).


Any help with being able to populate the values in array c back into array a in order to get to array d, would be much appreciated.



asked 2 mins ago







populate values from one numpy array into another

Aucun commentaire:

Enregistrer un commentaire