官方文档:https://numpy.org/doc/stable/
¶ numpy.array
¶ 从python list创建
np.array([1, 2, 3]) |
¶ 从多个python list创建一维数组
如果是确定数量的list,可以用np.concatenate
:
a = [1, 2, 3] |
输出:array([1, 2, 3, 4, 5, 6])
来源:https://stackoverflow.com/a/54773471/13688160
如果有不定数量的list,用迭代器:
listOfLists = [[1, 2, 3], [4, 5, 6]] |
输出:
array([1, 2, 3, 4, 5, 6]) |
¶ 等差数列
文档:https://numpy.org/doc/stable/reference/generated/numpy.linspace.html
numpy.linspace(start, stop, num=50, endpoint=True, retstep=False, dtype=None, axis=0) |
¶ 二分搜索
https://numpy.org/doc/stable/reference/generated/numpy.searchsorted.html
left相当于lower_bound, right相当于upper_bound, 默认是left。
¶ 矩阵
¶ percentile
https://numpy.org/doc/stable/reference/generated/numpy.percentile.html#
# 10000个0到1的随机数 |