删除行和列的dumpy数组,给定的信息删除在另一个向量数组中
我有以下代码:
deleterowandcolumns = np.array([0,3])
original = np.array ([
[1, 2, 3, 4],
[5, 6, 7, 8],
[9, 10, 11, 12],
[13, 14, 15, 16]
])
要删除的行和列包含在deleterowandColumns
array中。我手动删除了指定的行和列,例如:
deleted = np.delete(original,(0,3), axis=0)
deleted = np.delete(deleted,(0,3), axis=1)
获得以下所需的输出:
[[ 6 7]
[10 11]]
但是,此方法是非常手动的,并且根本不使用deleterowandcolumns
randay。有没有有效的方法?
I have the following code:
deleterowandcolumns = np.array([0,3])
original = np.array ([
[1, 2, 3, 4],
[5, 6, 7, 8],
[9, 10, 11, 12],
[13, 14, 15, 16]
])
The rows and columns to delete is contained in the deleterowandcolumns
array. Manually, I deleted the specified rows and columns like:
deleted = np.delete(original,(0,3), axis=0)
deleted = np.delete(deleted,(0,3), axis=1)
The following required output is obtained:
[[ 6 7]
[10 11]]
However this method is very manual and does not use the deleterowandcolumns
array at all. Is there an efficient way of doing this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论