导入
import numpy as np
argsort()
- numpy中的排序函数
- 返回的是数组中从小到大的索引值
from numpy import *
test=[5,2,3,4,1]
print(agrsort(test))
#1,2,3,4,5
有些函数不一定是numpy中的
Counter()
python中的计数器,用于统计指定对象出现的次数
例如在knn中,统计分类对象出现的次数
import collections
v= collections.Counter('bnbnbnbaa')
print(obj)
#Counter({'b': 4, 'a': 2, 'n': 3})
most_common()
一般和counter搭配使用效果更加
Counter(x).most_common(3)
出现次数最多的前n个元素及其次数
就是R里面的topn()