国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

numpy.delete刪除一列或多列的方法

2020-01-04 15:31:05
字體:
供稿:網(wǎng)友

基礎(chǔ)介紹:

numpy.deletenumpy.delete(arr, obj, axis=None)[source] Return a new array with sub-arrays along an axis deleted. For a one dimensional array, this returns those entries not returned by arr[obj]. Parameters:	 arr : array_like  Input array. obj : slice, int or array of ints  Indicate which sub-arrays to remove. axis : int, optional  The axis along which to delete the subarray defined by obj. If axis is None, obj is applied to the flattened array. Returns:	 out : ndarray  A copy of arr with the elements specified by obj removed. Note that delete does not occur in-place. If axis is None, out is a flattened array.

示例:

1.刪除一列

>>> dataset=[[1,2,3],[2,3,4],[4,5,6]] >>> import numpy as np >>> dataset = np.delete(dataset, -1, axis=1) >>> dataset array([[1, 2],   [2, 3],   [4, 5]]) 

2.刪除多列

arr = np.array([[1,2,3,4], [5,6,7,8], [9,10,11,12]]) np.delete(arr, [1,2], axis=1) array([[ 1, 4],   [ 5, 8],   [ 9, 12]]) 

以上這篇numpy.delete刪除一列或多列的方法就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持VEVB武林網(wǎng)。


注:相關(guān)教程知識閱讀請移步到python教程頻道。
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 富宁县| 周宁县| 萨迦县| 甘泉县| 竹溪县| 乾安县| 宜兴市| 额济纳旗| 绥江县| 扎鲁特旗| 泊头市| 长春市| 麻阳| 大连市| 苍溪县| 阿鲁科尔沁旗| 克什克腾旗| 容城县| 辰溪县| 曲松县| 普格县| 岳阳市| 聊城市| 南雄市| 台前县| 宜黄县| 科尔| 安顺市| 措勤县| 双辽市| 安顺市| 景东| 保山市| 襄樊市| 沿河| 建宁县| 汝南县| 来凤县| 仙游县| 武宁县| 泗水县|