티스토리 뷰

카테고리 없음

Numpy

nickas 2019. 7. 14. 23:33

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/

 

Numpy에서 np.sum 함수의 axis 이해

Numpy의 sum은 유용한 함수입니다. 그러나 처음 sum 함수를 사용할 때 axis 파라미터가 무엇을 의미하는지 혼동되는 것이 사살입니다. axis의 의미를 정리합니다.

taewan.kim

 

최근에 올라온 글
글 보관함