Skip to content

Instantly share code, notes, and snippets.

@Robofied
Created February 15, 2019 18:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Robofied/b1b83ff8a78b8626ca0d86e65a341873 to your computer and use it in GitHub Desktop.
Save Robofied/b1b83ff8a78b8626ca0d86e65a341873 to your computer and use it in GitHub Desktop.
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