Kaveh P. Yousefi
Kaveh P. Yousefi

Reputation: 185

Save a sliced numpy matrix into another numpy array

Well, this is a very quick question. I want to slice an array (numpy array), and save it in another array (define it in another numpy array). I used the following codes which is wrong. I'd be happy if you help me correct my codes.

below, aa is a new numpy one-dimensional array that I wanna define. cc is a numpy 2-dimensional array.

aa = cc[1:,3]

Thanks in advance for your supports.

Upvotes: 2

Views: 127

Answers (1)

Matthieu Brucher
Matthieu Brucher

Reputation: 22023

If you use aa like that, you will create a new variable.

You need to do:

aa[:] = cc[1:,3]

This way you tell to replace the content of aa and not the variable itself.

Upvotes: 1

Related Questions