![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
numpy学习
zlibo丶
这个作者很懒,什么都没留下…
展开
-
numpy-np.partition的使用
官方文档:https://numpy.org/doc/stable/reference/generated/numpy.partition.html官方给出的说明是:即:以第'k-th'位置为基准,该位置的元素位于对原始数组排序之后的位置,大于该元素值的元素被放置在该元素的后面,小于该元素值的元素被放置在该元素的前面,前后两端的元素排列顺序无要求。代码测试:a = np.array([3, 4, 2, 1]) # [1, 2, 3, 4]print(a)print(np.part原创 2021-01-28 14:54:19 · 1463 阅读 · 2 评论 -
numpy-np.searchsorted的用法
官方文档:https://numpy.org/doc/stable/reference/generated/numpy.searchsorted.html官方给出的说明是:即:查询给定数据在原始数组中的插入位置,而不改变原始数组的排列顺序。代码测试:print(np.searchsorted([1,2,3,4,5], 3))print(np.searchsorted([1,2,3,4,5], 3, side='right'))print(np.searchsorted([1,2,3原创 2021-01-25 11:47:11 · 573 阅读 · 0 评论 -
numpy-np.lexsort的用法
官方文档:https://numpy.org/doc/stable/reference/generated/numpy.lexsort.html官方给出的说明是:numpy.lexsort(keys, axis=-1)Perform an indirect stable sort using a sequence of keys.Given multiple sorting keys, which can be interpreted as columns in a spreadsheet,原创 2021-01-25 11:22:44 · 4310 阅读 · 1 评论 -
numpy-np.ix_函数的使用
官方文档:https://numpy.org/doc/stable/reference/generated/numpy.ix_.html#numpy.ix_,给出的用法是:numpy.ix_(*args)'''Construct an open mesh from multiple sequences.This function takes N 1-D sequences and returns N outputs with N dimensions each, such that the s原创 2021-01-12 16:35:46 · 508 阅读 · 0 评论 -
numpy-numpy.sum()中‘keepdims‘参数的作用
在numpy的许多函数中,会出现'keepdims'参数,以numpy.sum()为例:官方文档中给出的解释:numpy.sum(a, axis=None, dtype=None, out=None, keepdims=<no value>, initial=<no value>, where=<no value>)'''keepdimsbool, optionalIf this is set to True, the axes which are re原创 2021-01-08 16:11:10 · 2014 阅读 · 0 评论 -
numpy-array初始化时指定的dtype=[(‘x‘,‘i4‘),(‘y‘,‘i4‘)]参数
今天看numpy文档时,遇到一个问题https://numpy.org/doc/stable/reference/generated/numpy.argsort.html#numpy.argsort,在初始化array时的参数dtype=[('x','i4'),('y','i4')],做个记录:x = np.array([(1, 1000), (0, 1111)], dtype=[('x', '<i4'), ('y', '<i4')])这里的dtype的作用:给array中初始化值指.原创 2021-01-07 11:03:37 · 3177 阅读 · 3 评论