Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Numpy
## Creating a new array.
e = np.array([21,22,23])
## Creating a new array by using copy function.
f = e.copy()
## Checking the ids of both arrays
#3 In this case also both will have different idsIn [13]:
print(id(e))
print(id(f))
#[Output]:
#2090543656512
#2090543655152
## See changes if value in any array is updated
## Assigning the new value to e
e[0] =24
##Priting to check the updated array.
print(e)
#[Output]:
#[24 22 23]
## Printing to check if the another array created using copy(), will be change or not?
## In this case it will not reflect the changes.
print(f)
#[Output]:
#[21 22 23]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.