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

12번째 줄: 12번째 줄:
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>



2021년 12월 12일 (일) 16:19 판

1 개요

NumPy foreach row
import numpy as np
m = np.matrix([[101,102,103,104],
               [201,202,203,204],
               [301,302,303,304]])
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 }}