Parthi
Parthi

Reputation: 135

Numpy array using expression

how can I create an np array using expression y1 = x, when x array is already defined

x = [1,2,5,7]

from this array x , I would like to create another array y1 using the expression

y1 = x

using numpy

Upvotes: 0

Views: 1477

Answers (1)

Syrius
Syrius

Reputation: 941

If you want a copy of the array it would be

import numpy as np
y1 = np.array(x)

Currently you just assign the list from x to y1. With this you create a new numpy array with the values from x.

Upvotes: 1

Related Questions