浏览次数:1479
, 标签:
python
import numpy as np >>> data=[[1,2,3],[2,3,4],[4,5,6]] >>> data [[1, 2, 3],
[2, 3, 4], [4, 5, 6]] >>> #列表的读取或删除某一列 >>> #1.读取 >>> data1=np.array(data) >>>
data1 array([[1, 2, 3], [2, 3, 4], [4, 5, 6]]) >>> data1[:,0] array([1, 2, 4])
2.删除 >>> np.delete(data1,0,axis=1) array([[2, 3], [3, 4], [5, 6]]) >>>
data1 array([[1, 2, 3], [2, 3, 4], [4, 5, 6]]) >>> #numpy数组的读取或删除某一列 >>>
data=np.array([[1,2,3],[2,3,4],[4,5,6]]) >>> data array([[1, 2, 3], [2, 3, 4],
[4, 5, 6]]) >>> #1.读取 >>> data[:,1] array([2, 3, 5]) >>> #2.删除 >>>
np.delete(data,1,axis=1) array([[1, 3], [2, 4], [4, 6]]) >>> data array([[1, 2,
3], [2, 3, 4], [4, 5, 6]])
原创文章,作者:admin,如若转载,请注明出处:https://b.nm169.com/u_admin/20210930_300/