티스토리 뷰
pip install numpy
import numpy as np
a = np.array([1, 2, 3])
a.ndim(Dimensitons)
a.shape(Shape)
a.dtype(Data type)
a.reshape([2, 4]) row, column, depth
a.astype('int32')
np.zeros([2, 3])
np.ones([2, 3])
np.empty((2, 3))
np.random.random((2, 3))
np.linspace(2, 10, 5)
np.arange(2, 10, 2)
np.arange(16)
a = np.array([1, 2, 3, 4, 5, 6, 7, 8])
a[2]
a[3:5]
a[:4:2] = 0
a[::-1]
a = np.arange(16, dtype='int32')
a = a.reshape([2, 2, 4])
a[0]
a[1, 0]
a[0,:,1:3]
a[1, 1, :-1]
Create an array with two fields, x and y:
x_array = np.array([(1.0, 2), (3.0, 4)], dtype=[('x', float), ('y', int)])
x_recarray = x_array.view(np.recarray)
http://taewan.kim/post/numpy_sum_axis/
최근에 올라온 글
글 보관함