簡體   English   中英

如何獲得2D陣列的一部分?

[英]How can get a part of a 2D array?

我有一個二維數組,形狀為(100,64)。 我需要獲得一個新數組,如(100,63),就像從工作表中刪除一列一樣。 那么我應該使用什么numpy函數來實現呢?

# Let X be my (100, 64) dataset, and i the column I want to delete
np.somefunction(X[:, :i], X[:, i:])

您可以使用delete

np.delete(X, i, axis=1)

hstack

np.hstack((X[:, :i-1], X[:, i:])

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM