Numpy Ndarray Operation
In last article we learnd about the basic of Numpy array and creation of ndarray object. In this article we are going to learn about the various operation on ndarray.
If you are new to numpy array then check previous article
- Introduction of numpy array ( Introduction-to-Numpy-Ndarray ) .
- Creation of numpy ndarray object ( Numpy-Ndarray-creation ) .
Follwing is the operation that can be performed on ndarray :
- Creating empty array :
import numpy as np x = np.array([ ]) # array creation using list |
Output :
[] [] {} |
- Creating one dimensions array
import numpy as np x = np.array([1,2,3]) # array creation using list |
Output:
[1 2 3] |
- Creating 2-dimensions array
import numpy as np x = np.array([[1,2],[3,4]]) # array creation using list |
Output :
[[1 2] |
- Creating ndarray with dtype parameter :
import numpy as np print (x) |
Output :
[ 11. 25. 68.] |
- Creating ndarray with the use of copy parameter
Copy parameter Return an array copy of the given object.
import numpy as np x[0] = 10 |
Output:
True |
- Creating ndarray with the use of ndmin parameter
Ndmin means minimum dimensions of the resulting array.
import numpy as np |
Output:
[[11 22 33 44]] |
Happy coding.....
- Please give your suggestion if you find anything incorrect. contact us at team@bitsolve.in