备注:原文发表于2022-01-10,会不定期更新各种常用函数

目录

np.full

代码

import numpy as np
a = np.full((2, 2), np.inf)
b = np.full((2, 2), 10)
print(a)
print(b)

结果

[[ inf  inf]
 [ inf  inf]]

[[10 10]
 [10 10]]

log1p(x)

percentile

  • https://numpy.org/doc/stable/reference/generated/numpy.percentile.html

  • 在python中计算一个多维数组的任意百分比分位数,此处的百分位是从小到大排列,只需用np.percentile即可。

searchsorted

  • https://blog.csdn.net/luhouxiang/article/details/106727250
l = np.searchsorted(a, 3, side='left')
print("left searchsorted index: ", l)
r = np.searchsorted(a, 3, side='right')
print("right searchsorted index: ", r)
print("item: ", a[l:r])
left searchsorted index: 3
right searchsorted index: 4
item: [3]