Skip to content

Instantly share code, notes, and snippets.

@Robofied
Created February 14, 2019 16:33
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/a38800a90b5390a72b17fa952cdef08e to your computer and use it in GitHub Desktop.
Save Robofied/a38800a90b5390a72b17fa952cdef08e to your computer and use it in GitHub Desktop.
Numpy
import numpy as np
## Creating array using list
x = np.array([2,3,1,0])
print(x)
#[Output]:
#[2 3 1 0]
## Creating array using the mixture of list and tuple
x = np.array([[1,2.0],[0,0],(1+1j,3.)])
print(x)
#[Output]:
#[[1.+0.j 2.+0.j]
# [0.+0.j 0.+0.j]
# [1.+1.j 3.+0.j]]
## With the help of asarray function
x = np.asarray([[1,2.0],[0,0],(1+1j,3.)])
print(x)
#[Output]:
#[[1.+0.j 2.+0.j]
# [0.+0.j 0.+0.j]
# [1.+1.j 3.+0.j]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment