Last active
September 23, 2015 14:50
-
-
Save thekensta/1a0c5aeab5eb17066f0f to your computer and use it in GitHub Desktop.
Numpy Basic Operations Cheat Sheet
This file contains hidden or 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
# Storing basic operations here, as I tend to forget them! | |
# Fill as required (or fill as forgotten?? :-) | |
# Repeat and Tile | |
# Repeat copies by element and flattens | |
# Tile copies sequences and preserves shape | |
a = np.array([1, 2, 3]) | |
print(np.tile(a, 2)) | |
# [1 2 3 1 2 3] | |
print(np.repeat(a, 2)) | |
# [1 1 2 2 3 3] | |
a = np.array([[1, 2], [3, 4]]) | |
print(np.tile(a, 2)) | |
# [[1 2 1 2] | |
# [3 4 3 4]] | |
print(np.repeat(a, 2)) | |
# [1 1 2 2 3 3 4 4] | |
# Ndarrays Vs Matrices | |
http://stackoverflow.com/questions/4151128/what-are-the-differences-between-numpy-arrays-and-matrices-which-one-should-i-u | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment