Python Forum

Full Version: Changing Values in a List
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I would like to replace all the values (1.3million) in column 3 with 0.00000000. Can someone please advise how I insert this in my code please?

file = 'Z_Before_After.txt'
data = np.genfromtxt(file)
xx = data[:, 0]
yy = data[:, 1]
elevation = data[:, 2]
initial = data[; 2]

with open(file, "w") as output:
    output.write(xx, yy, initial, elevation)
3560181.703 -3384947.321 -5.02245
3560191.703 -3384947.321 -4.88665
3560201.703 -3384947.321 -4.76042
3560211.703 -3384947.321 -4.66599
3560221.703 -3384947.321 -4.60876
3560231.703 -3384947.321 -4.55424
3560241.703 -3384947.321 -4.49973
3560251.703 -3384947.321 -4.35269
3560261.703 -3384947.321 -4.11991
Try like
import numpy as np
data = np.array([[1,2,3],[4,5,6],[7,8,9]])
data[:, 2] = np.zeros(3)
data
Output:
array([[1, 2, 0], [4, 5, 0], [7, 8, 0]])