您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

通过python迭代在numpy / scipy中建立数组?

通过python迭代在numpy / scipy中建立数组?

如果我正确理解您的问题,这应该做您想要的:

# the array passed into your function
ax = NP.random.randint(10, 99, 20).reshape(5, 4)

# just define a function to operate on some data
fnx = lambda x : NP.sum(x)**2

# apply the function directly to the numpy array
new_row = NP.apply_along_axis(func1d=fnx, axis=0, arr=ax)

# 'append' the new values to the original array
new_row = new_row.reshape(1,4)
ax = NP.vstack((ax, new_row))
python 2022/1/1 18:46:28 有288人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶