a=[1,2,3,4]
(1)b = a
(2)a.copy()
(3)import copy
copy.copy(a)
import numpy as np
a=[1,2,3,4]
np.sort(a)
-> array([1, 2, 3, 4])
a = np.arange(1,101).reshape(10,10)
a
->
array([[ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
[ 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],
[ 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],
[ 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],
[ 41, 42, 43, 44, 45, 46, 47, 48, 49, 50],
[ 51, 52, 53, 54, 55, 56, 57, 58, 59, 60],
[ 61, 62, 63, 64, 65, 66, 67, 68, 69, 70],
[ 71, 72, 73, 74, 75, 76, 77, 78, 79, 80],
[ 81, 82, 83, 84, 85, 86, 87, 88, 89, 90],
[ 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]])
a[[4, 4, 6, 7], [2, 7, 4, 0]]
->
array([43, 48, 65, 71])
: 행렬을 나누는데 hsplit 은 열을 기준으로, vsplit은 행을 기준으로 나눈다.
(h:믐 ,v:ㅁㅣㅁ)
array([[3, 3, 0],
[3, 3, 3],
[0, 3, 3]])
->
a = np.full((3,3),3)
a[[0,2],[2,0]] = 0
a
a = np.array([[1,2,4,7], [9,88,6,45], [9,76,3,4]])
a
array([[ 1, 2, 4, 7],
[ 9, 88, 6, 45],
[ 9, 76, 3, 4]])
np.max(a)
->88
np.max(a, axis=0)
->array([ 9, 88, 6, 45])
np.argmax(a)
->5
np.argmax(a, axis=0)
->array([1, 1, 1, 1], dtype=int64)
``python
array([[ 0, 1, 8, 27, 64],
[ 125, 216, 343, 512, 729],
[ 1000, 1331, 1728, 2197, 2744],
[ 3375, 4096, 4913, 5832, 6859],
[ 8000, 9261, 10648, 12167, 13824]])
->
a = np.array([i**3 for i in range(25)]).reshape(5,5)
a
a=(np.arange(25)**3).reshape(5, 5)
a
np.where(a < 500, 0,1)
->
array([[0, 0, 0, 0, 0],
[0, 0, 0, 1, 1],
[1, 1, 1, 1, 1],
[1, 1, 1, 1, 1],
[1, 1, 1, 1, 1]])
np.mean(a, axis=1)
->
array([ 20., 385., 1800., 5015., 10780.])
a = np.arange(1, 100, 15)
a
->
array([ 1, 16, 31, 46, 61, 76, 91])
array([[[ 0, 1, 2],
[ 3, 4, 5],
[ 6, 7, 8],
[ 9, 10, 11]],
[[12, 13, 14],
[15, 16, 17],
[18, 19, 20],
[21, 22, 23]],
[[24, 25, 26],
[27, 28, 29],
[30, 31, 32],
[33, 34, 35]]])
->
np.arange(36).reshape(3,4,3)
arr1=np.array([[1,2, 1],[3,4, 2]])
arr2=np.array([[5,6],[7,8],[1,2]])
array([[20, 24],
[45, 54]])
-> arr1
array([[1, 2, 1],
[3, 4, 2]])
-> arr2
array([[5, 6],
[7, 8],
[1, 2]])
-> np.matmul(arr1, arr2), arr1@arr2
array([[20, 24],
[45, 54]])