📜  sciPy stats.threshold()函数| Python

📅  最后修改于: 2022-05-13 01:55:05.305000             🧑  作者: Mango

sciPy stats.threshold()函数| Python

scipy.stats.threshold(a, threshmin=None, threshmax=None, newval=0)函数剪切给定数组。超出设置限制的值可以由“newval”参数替换。

代码 #1:工作

# stats.threshold() method  
import numpy as np
from scipy import stats
   
arr1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
  
  
print ("\narr1 : ", arr1)
  
print ("\nclipped arr1 : \n", stats.threshold(
        arr1, threshmin = 2, threshmax = 8, newval =-1))

输出 :

arr1 :  [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

clipped arr1 : 
[-1 -1 2 3 4 5 6 7 8 -1]