"NumPy foreach row"의 두 판 사이의 차이

(새 문서: ==개요== ;NumPy foreach row <syntaxhighlight lang='python' run> import numpy as np m = np.matrix([[101,102,103,104], [201,202,203,204], [301,302,303,3...)
 
 
(같은 사용자의 중간 판 4개는 보이지 않습니다)
2번째 줄: 2번째 줄:
;NumPy foreach row
;NumPy foreach row


<syntaxhighlight lang='python' run>
<syntaxhighlight lang='python' notebook>
import numpy as np
import numpy as np
m = np.matrix([[101,102,103,104],
m = np.matrix([[101,102,103],
               [201,202,203,204],
               [201,202,203],
               [301,302,303,304]])
               [301,302,303],
              [401,402,403]])
m
</syntaxhighlight>
<syntaxhighlight lang='python' notebook>
for i, row in enumerate(m):
for i, row in enumerate(m):
   print(i, row)
   print(i, row)
</syntaxhighlight>
</syntaxhighlight>
 
<syntaxhighlight lang='python' notebook>
def myfunc(x):
  print(x)
np.apply_along_axis(myfunc, axis=1, arr=m)
</syntaxhighlight>
<syntaxhighlight lang='python' notebook>
np.apply_along_axis(lambda x: print(x), axis=1, arr=m)
</syntaxhighlight>


==같이 보기==
==같이 보기==
* [[NumPy apply_along_axis()]]
* [[NumPy foreach column]]
* [[Python foreach]]
* [[Python foreach]]


[[분류: NumPy]]
[[분류: NumPy]]

2021년 12월 12일 (일) 16:23 기준 최신판

1 개요[ | ]

NumPy foreach row
import numpy as np
m = np.matrix([[101,102,103],
               [201,202,203],
               [301,302,303],
               [401,402,403]])
m
for i, row in enumerate(m):
  print(i, row)
def myfunc(x):
  print(x)
np.apply_along_axis(myfunc, axis=1, arr=m)
np.apply_along_axis(lambda x: print(x), axis=1, arr=m)

2 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}