Skip to content

Instantly share code, notes, and snippets.

@Robofied
Created February 15, 2019 12:08
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/fe6f5438973ef884cd37d202a45008a8 to your computer and use it in GitHub Desktop.
Save Robofied/fe6f5438973ef884cd37d202a45008a8 to your computer and use it in GitHub Desktop.
Numpy
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