怎么取出numpyndarray的第0列并转置
可以使用numpy的切片操作和转置操作来取出第0列并转置,例如:
import numpy as np
arr = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
col0 = arr[:, 0] # 取出第0列
col0 = col0.reshape((-1, 1)) # 转置
print(col0)
输出结果为:
[[1]
[4]
[7]]
原文地址: https://www.cveoy.top/t/topic/fRss 著作权归作者所有。请勿转载和采集!