본문 바로가기

Python

Python_N-001. basic commend in Numpy

A summary of the basic commands for using NumPy.

 

Operation Command Description
Import NumPy import numpy as np Import the NumPy library
Create Array np.array( [1, 2, 3] ) Create an array from a list
Array of Zeros np.zeros( 5 ) Create an array of zeros
Array of Ones np.ones( 5 ) Create an array of ones
Identity Matrix np.eye(3) Create a 3x3 identity matrix
Full Array
np.full(  (3, 3),  fill_value  ) Create an array filled with a specific value
Range Array np.arange(10)
np.range(10)
Create an array with a range of values
  arange() : float
  range() : integer
Linspace np.linspace(0, 1, 10) Select elements based on a condition
Arithmetic Operation array + 2 Add 2 to each element of the array
Element-wise Addition array_1 + array_2 Add two arrays element-wise
Reshape Array array.reshape((5, 1)) Reshape an array
Access Element array[0] Access the first element of the array
Slice Array array[1:4] Access a slice of the array
Sum np.sum(array) Calculate the sum of the array elements
Mean np.mean(array) Calculate the mean of the array elements
Max np.max(array) Find the maximum value in the array
Min np.min(array) Find the minimum value in the array

 

'Python' 카테고리의 다른 글

Python_N-003. Data Type in array  (0) 2025.01.19
Python_N-002. random module  (0) 2025.01.18
Python_G-010. class vs instance  (0) 2025.01.17
Python_G-009. import vs from ... import vs from... import *  (0) 2025.01.17
Python_G-008. Function  (0) 2025.01.16