python numpy如何沿中心旋转3D阵列
我需要转换以下3D数组。 我需要第1列才能成为1'strow, 2'nd列成为2'第2行,而第3列成为第3行。
3 4 5 4 7 3
7 1 2 => 5 1 4
4 5 6 6 2 5
6 7b 1 7b 3 6
3 4 5 => 1 4 7b
7b 1 2 2 5 1
这项工作 print(np.rot90(r [6],3))
在2D阵列上,我需要在3D阵列中
我需要它为此数组工作
[[['6' '7b' '1']
['3' '4' '5']
['7b' '1' '2']]
[['3' '4' '5']
['7' '1' '2']
['4' '5' '6']]
[['7' '1' '2']
['4s' '5' '6']
['1' '2' '3']]]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
似乎 使用 内部,因此我们可以使用
np.transpose
直接用于您的情况。 iiuc,您可以将阵列转换为第二个&第三维,然后根据需要对其进行反转:它将获得与
np.Rot90
相同的结果,该结果由 @szczesny在评论中。It seems
np.rot90
usenp.transpose
internally, so we can usenp.transpose
instead that directly for your case. IIUC, you can transpose the array for 2nd & 3rd dimensions and then reverse them as needed:It will get the same results as
np.rot90
that well explained by @Szczesny in the comments.