Last active
February 12, 2018 11:52
-
-
Save Fhernd/5195508b5b159e45f569d88caff5058e to your computer and use it in GitHub Desktop.
Copia de arreglos con Numpy en Python.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
# Crea arreglo con unos: | |
unos = np.ones((6, 1), dtype=int) | |
print(unos) | |
print('') | |
# Asignación de la referencia de un arreglo a otra variable: | |
unos_2 = unos | |
# Copia shallow: | |
vista = unos.view() | |
# Comprueba si las dos variables apuntan al mismo arreglo: | |
print(vista.base is unos) | |
print('') | |
# Cambiar los metadatos del arreglo: | |
# En particular, cambia la forma del arreglo a matriz: | |
vista.shape = 2,3 | |
print(unos) | |
print(vista) | |
print('') | |
copia = unos.copy() | |
print(unos is copia) | |
print(unos is copia.base) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment