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

 
(같은 사용자의 중간 판 2개는 보이지 않습니다)
4번째 줄: 4번째 줄:
<syntaxhighlight lang='python' notebook>
<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
m
</syntaxhighlight>
</syntaxhighlight>
12번째 줄: 13번째 줄:
for i, row in enumerate(m):
for i, row in enumerate(m):
   print(i, row)
   print(i, row)
</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>
</syntaxhighlight>


==같이 보기==
==같이 보기==
* [[NumPy apply_along_axis()]]
* [[NumPy foreach column]]
* [[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 }}