numpy is a library for efficient numerical calculation in the Python language. numpy has the following advantages: --High-speed calculation using vectorization notation --Efficient descriptive statistical data manipulation --Condition description in the audience
In ndarray, vectorization notation enables high-speed batch calculation for arrays.
↓ ↓ ↓ ↓ ↓ ↓ ↓ Contents of your article
ndarray.py
───────
#### **`ndarray1.py`**
```python
↑↑↑↑↑↑↑ Contents of edit request
import numpy as np
ndarray1 = np.array([1,2,3,4,5])
↓ ↓ ↓ ↓ ↓ ↓ ↓ Contents of your article
print(ndarray)
# Output result [1 2 3 4 5]
───────
print(ndarray1)
↑↑↑↑↑↑↑ Contents of edit request
↓ ↓ ↓ ↓ ↓ ↓ ↓ Contents of your article ndarray2 = np.arrange(1,6,1) ───────
Output result
[1 2 3 4 5]
ndarray2.py
ndarray2 = np.arrange(1,6,1)
↑↑↑↑↑↑↑ Contents of edit request
print(ndarray2)
↓ ↓ ↓ ↓ ↓ ↓ ↓ Contents of your article
# Output result [1 2 3 4 5]
print(np.ones(5))
# Output result [1 1 1 1 1]
np.The array function can pass a multidimensional list.
ndarry2.py
ndarray4 = np.array([[1,2,3],[4,5,6]])
print(ndarray4)
# Output result [[1 2 3] [4 5 6]]
-shape → shape of the array -size → Total number of elements in the array -ndim → Number of dimensions of array
ndarray3.py
ndarray = np.array([[1, 2, 3], [4, 5, 6]])
print(ndarray.shape)
print(ndarray.size)
print(ndarray.ndim)
# Output result (2,3)
# Output result 6
# Output result 2
───────
#### **`Output result`**
```text
[1 2 3 4 5]
↑↑↑↑↑↑↑ Contents of edit request
Recommended Posts