how to replace 4th and 5th column values in utl by new_values array and keep the remaining columns as it is
utl = np.array([[ 3. , 134.4 , 17. , 135.05 , 22. , 135.25 , 0.04 ],
[ 12. , 134.3 , 17. , 135.05 , 22. , 135.8 , 0.15 ]])
new_values=np.array([[ 27., 135.45],
[ 27., 136.55]])
i tried this but it does not work
# utl[:,[4,5]] = new_values
# utl[:,4] = new_values[:,0]
output must be
#values changed
[[ 3. , 134.4 , 17. , 135.05 , | 27. , 135.45 |, 0.04 ],
[ 12. , 134.3 , 17. , 135.05 , | 27. , 136.55 |, 0.15 ]])
this works fine, as expected:
utl[:, [4,5]] = new_values
output:
array([[ 3. , 134.4 , 17. , 135.05, 27. , 135.45, 0.04],
[ 12. , 134.3 , 17. , 135.05, 27. , 136.55, 0.15]])
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.