0

I have this 2D array.

[(476301.98163511883, 6176897.129456658)
 (476723.365551495, 6176895.078376785)
 (477124.59457628336, 6176893.28525448)
 (477525.82249430567, 6176891.306532074)
 (477927.0510582989, 6176889.4760845825)
 (477925.0121537624, 6176487.379134962)
 (477922.97333802003, 6176085.2824224755)
 (477920.93404681794, 6175683.074655607)
 (477918.79328165855, 6175260.834659822)]

I'm trying to add 10 to "X" the first column and 20 to the "Y" column. I can't figure out how to access each column while keeping the array structure as is.

I can do something like this

x = array['X'] + 10
y = array['Y'] + 20

However now the array is split and a need the x, y pair together like in the original array. Thanks

1 Answer 1

2

I guess your columns are named 'X' and 'Y', and that array is a numpy.array? In that case you can edit inplace by using the += operator:

array['X'] += 10
array['Y'] += 20

or, if they are not named

array[:, 0] += 10
array[:, 1] += 20

This is the same as

array['X'] = array['X'] + 10
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.