1. Grundlagen¶
aus https://numpy.org/doc/stable/user/absolute_beginners.html
1.1. basic arrays¶
import numpy as np
a = np.array([1, 2, 3, 4, 5, 6])
a
array([1, 2, 3, 4, 5, 6])
b = np.array([[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]])
b
array([[ 1, 2, 3, 4],
[ 5, 6, 7, 8],
[ 9, 10, 11, 12]])
1.2. Null Array¶
np.zeros(2)
array([0., 0.])
1.3. Ein Array¶
np.ones(2)
array([1., 1.])
1.4. Array mit range¶
np.arange(2, 9, 2)
array([2, 4, 6, 8])
1.5. Array mit Einteilung¶
np.linspace(0, 10, num=5)
array([ 0. , 2.5, 5. , 7.5, 10. ])
1.6. sortieren¶
arr = np.array([2, 1, 5, 3, 7, 4, 6, 8])
np.sort(arr)
array([1, 2, 3, 4, 5, 6, 7, 8])