numpy
文章平均质量分 74
pythonplusvabel
这个作者很懒,什么都没留下…
展开
-
统计出现次数最多的元素值及相关
numpy:>>>x = np.array([2,3,1,1,4])>>>count = np.bincount(x)array([0, 2, 1, 1, 1])>>>common_value = np.argmax(count)1dict:>>>a={'a':4,'b':2,'c':3,'d':1}>>转载 2018-03-05 09:58:30 · 2959 阅读 · 0 评论 -
numpy矩阵中令小于0的元素改为0
>>> import numpy as np>>> a = np.random.randint(-5, 5, (5, 5))>>> aarray([[-4, -4, -5, 2, 1], [-1, -2, -1, 3, 3], [-1, -2, 3, -5, 3], [ 0, -3, ...转载 2018-04-08 12:33:33 · 69568 阅读 · 0 评论 -
numpy中获得元素下标的方法
numpy.where¶numpy.where(condition[, x, y])Return elements, either from x or y, depending on condition.If only condition is given, return condition.nonzero().Parameters:condition : array_like, boolWhen...转载 2018-06-26 09:41:09 · 23421 阅读 · 6 评论