E
E
egocentrist2015-01-09 08:59:06
Python
egocentrist, 2015-01-09 08:59:06

Numpy: linked arrays?

>>> import numpy as np
>>> a = np.array([1,2,3])
>>> a
array([1, 2, 3])
>>> b=a
>>> b
array([1, 2, 3])
>>> b[0]=321
>>> a
array([321,   2,   3])

Why does a change when b changes? How to avoid it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Max, 2015-01-09
@egocentrist

two variables point to one object.
You can avoid it like this

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question