Académique Documents
Professionnel Documents
Culture Documents
output
[[0.00000000e+000 0.00000000e+000 0.00000000e+000]
[0.00000000e+000 0.00000000e+000 6.73905541e-321]
[8.90060779e-307 0.00000000e+000 0.00000000e+000]]
2- print(a.shape)
print(a.dtype)
output
(3, 3)
float64
ouput
[[0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0.]]
float64
4- a.dtype=int
output
[1. 1. 1. 1. 1.]
6- 9 row 10 column, data type= int, value =125
a=np.zeros(9,5, dtype=int) +125
a
output
[1 2 3]
[4 5 6]
[[1 2 3]
[4 5 6]]
(2, 3)
output
[1 2 3]
[4 5 6]
[1 2 3 4 5 6]
(6,)
Output
[11 22 33 44 55]
<class 'numpy.ndarray'>
[[11 22]
[33 44]
[55 66]]
<class 'numpy.ndarray'>
output
11
55
11
[11 22]
[11 22 33 44 55]
11
[44 55]
[[11 22]
[44 55]
[77 88]]
[33 66 99]
[[11 22 33]
[44 55 66]]
[[77 88 99]]
[33, 44],
[55, 66]]
# array of data
data = array(data)
print('Rows: %d' % data.shape[0])
print('Cols: %d' % data.shape[1])
Rows: 3
Cols: 2
# reshape 1D array to 2D
from numpy import array
# define array
data = array([11, 22, 33, 44, 55])
print(data.shape)
# reshape
data = data.reshape((data.shape[0], 1))
print(data.shape)
(5,)
(5, 1)
array([[11],
[22],
[33],
[44],
[55]])
# reshape 2D array to 3D
from numpy import array
# list of data
data = [[11, 22],
[33, 44],
[55, 66]]
# array of data
data = array(data)
print(data.shape)
# reshape
data = data.reshape((data.shape[0], data.shape[1], 1))
print(data.shape)
array([[[11],
[22]],
[[33],
[44]],
[[55],
[66]]])
import numpy as np
a=np.arange(75).reshape((3,5,5))
a[1, 0:, 1:-1]
z, x, y
start:stop:step
Home work
all column slice one row and one row miss, and print descending row
array
Start, end, step
Home work
Chase Game
1-64