Skip to content

Instantly share code, notes, and snippets.

💭
Towards Singularity

Robofied Robofied

💭
Towards Singularity
Block or report user

Report or block Robofied

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View numpy_indexing_slicing3.py
## Simple without stride and slice
print(y[1,2])
#[Output]:
#9
## Using ":" will go from start to end
## Without stride
print("This is without stride-:")
View numpy_indexing_slicing2.py
import numpy as np
x = np.arange(10)
print(x[2:5])
print(x[2:5:2])
#[Output]:
#[2 3 4]
#[2 4]
View numpy_indexing_slicing1.py
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
View numpy_array_creation4.py
""""It is almost similar to the last function arange we have discussed with the parameters but the only difference is,
it doest not exlude the end value."""
x = np.linspace(1., 4., 5)
print(x)
#[Output]:
#[1. 1.75 2.5 3.25 4. ]
View numpy_array_creation3.py
x = np.arange(10)
print(x)
#[Output]:
#[0 1 2 3 4 5 6 7 8 9]
##It will create an array from 2 to 10(as last value is excluded)
y = np.arange(2, 11, dtype=np.float)
print(y)
View numpy_array_creation2.py
import numpy as np
x = np.zeros((3, 3))
print(x)
#[Output]:
#[[0. 0. 0.]
# [0. 0. 0.]
# [0. 0. 0.]]
View numpy_array_creation1.py
import numpy as np
## Creating array using list
x = np.array([2,3,1,0])
print(x)
#[Output]:
#[2 3 1 0]
View numpy_array_attributes.py
import numpy as np
a = np.array([[1,2,3],[4,5,6],[7,8,9],[10,11,12]])
print(a)
#[Output]:
#[[ 1 2 3]
# [ 4 5 6]
# [ 7 8 9]
# [10 11 12]]
View numpy_datatype2.py
## Creating a int8 type of array.
z = np.int8([-12,2,3])
## Printing the array.
print(z)
#[Output]:
#array([-12, 2, 3], dtype=int8)
## Creating an array with datatype -> uint.
View numpy_datatype1.py
## importing numpy for creating numpy array.
import numpy as np
## Creating a normal integer array.
x = np.int_([1,2,4])
## Printing the created array.
x
#[Output]:
You can’t perform that action at this time.