Skip to content

Instantly share code, notes, and snippets.

@Robofied
Created February 15, 2019 18:32
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/a7be0a3dbe427fcf6c46e29369633bcd to your computer and use it in GitHub Desktop.
Save Robofied/a7be0a3dbe427fcf6c46e29369633bcd to your computer and use it in GitHub Desktop.
Numpy
## Creating a new array
c = np.array([11,12,13])
## Creating another array using view function
d = c.view()
## Checking the value of "d"
print(d)
#[Output]:
#[11 12 13]
## Checking the id'd of both array
## In views id will be different for both the arrays.
print(id(c))
print(id(d))
#[Output]:
#2090543654432
#2090543652992
## See changes if value in any array is updated
## Assigning the new value in "d"
d[0] = 14
print(d)
#[Output]:
#[14 12 13]
## Checking if changes is reflected in c or not.
print(c)
#[Output]:
#[14 12 13]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment