Initializing arrays ¶
np.linspace
¶
Creates an array with evenly spaced values over a specified range.
In [ ]:
Copied!
import numpy as np
import numpy as np
In [25]:
Copied!
linspace_array = np.linspace(0, 1, 5)
print(linspace_array)
linspace_array = np.linspace(0, 1, 5)
print(linspace_array)
[0. 0.25 0.5 0.75 1. ]
In [26]:
Copied!
arange_array = np.arange(10)
print(arange_array)
arange_array = np.arange(10)
print(arange_array)
[0 1 2 3 4 5 6 7 8 9]
In [27]:
Copied!
zeros_array = np.zeros(5)
print(zeros_array)
zeros_array = np.zeros(5)
print(zeros_array)
[0. 0. 0. 0. 0.]
In [28]:
Copied!
full_array = np.full((2, 2), np.nan)
print(full_array)
full_array = np.full((2, 2), np.nan)
print(full_array)
[[nan nan] [nan nan]]