Created
February 15, 2019 12:08
-
-
Save Robofied/fe6f5438973ef884cd37d202a45008a8 to your computer and use it in GitHub Desktop.
Numpy
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 | |
##Let's first create 1-D array | |
x = np.arange(10) | |
print(x) | |
print(x[0]) | |
#[Output]: | |
#[0 1 2 3 4 5 6 7 8 9] | |
#0 | |
print(x[1]) | |
#[Output]: | |
#1 | |
## Converting to multidimensional array | |
x.shape = (2,5) | |
## Now it is multidimensional array of shape-> (2,5) | |
print(x) | |
print(x[0]) | |
#[Output]: | |
#[[0 1 2 3 4] | |
# [5 6 7 8 9]] | |
#[0 1 2 3 4] | |
## See the different method for indexing element in multidimensional | |
print(x[1,2]) | |
print(x[1][2]) | |
#[Output]: | |
#7 | |
#7 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment