Python Part 4: Numpy Flashcards
axis = 0 in a 2d array
vertical or horizontal?
vertical
axis = 1
vertical or horizontal for 2d array?
horizontal
create an array with the numbers 1, 2, 3, 4, 5
arr = np.array([1,2,3,4,5])
arr = np.arange(1,6)
create an array of 10 zeros
create an array of ones with the dimensions 3x4
arr1 = np.zeros(10)
arr2 = np.ones((3,4))
create an array with a range of numbers
- create an array with 0,1,2
- create an array with 3,4,5
np.arange(range)
zB
arr1=np.arange(3)
arr2=np.arange(3,6)
np.random.randint(): 4 occurrences
numpy.random.rand():
Create an array of the given shape and populate it with random samples from a uniform distribution over [0, 1).
np.mean(): 4 occurrences
Standard Deviation?
np.std(array)
also
np.std(array, axis = x)
Variance ?
np.var(array)
Array Reshaping ?
arr.reshape(new dimensions)
arr = np.arange(12)
newarr = arr.reshape(4,3)
print(newarr)
arr = np.arange(12)
newarr = arr.reshape(4,3)
print(newarr)
output?
[[ 0 1 2]
[ 3 4 5]
[ 6 7 8]
[ 9 10 11]]
arr1=np.arange(3)
arr2=np.arange(3,6)
output arrays?
[0 1 2]
[3 4 5]
numpy.random.randn():
Generate random numbers from a standard normal distribution
numpy.random.randint():
Generate random integers between specified limits.