Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.