[英]How can get a part of a 2D array?
I have a 2d array with shape (100, 64). 我有一个二维数组,形状为(100,64)。 I need to obtain a new array like (100, 63), just like deleting one column from a sheet.
我需要获得一个新数组,如(100,63),就像从工作表中删除一列一样。 So what numpy function should I use to obtain this?
那么我应该使用什么numpy函数来实现呢?
# Let X be my (100, 64) dataset, and i the column I want to delete
np.somefunction(X[:, :i], X[:, i:])
You can use delete
: 您可以使用
delete
:
np.delete(X, i, axis=1)
or hstack
: 或
hstack
:
np.hstack((X[:, :i-1], X[:, i:])
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.