np.percentile()函数超详解 异常值极端值百分位四分位数

20211115

当有空值存在时,四分位数会是空值

20211019

https://www.zhihu.com/question/58421946
https://baike.baidu.com/item/%E5%9B%9B%E5%88%86%E4%BD%8D%E6%95%B0/5040599?fr=aladdin
上四分位数是大的那端

https://jingyan.baidu.com/article/20095761f8299dcb0621b455.html
计算步骤

https://zhuanlan.zhihu.com/p/235345817?utm_source=wechat_session
四分位数
顺序从1开始计数 这里的计算也是不对的,最好按numpy默认的配置计算的结果为准

在这里插入图片描述
举例 数列 1 2 3 4 5 6 7 8

上四分位=2x(3-2)*0.75=2.75

第一步 (n+1)/4=求的位置

aa=ndarray=[[1,2,3,4,5,6,7,8,9,10,100],[1,2,2,4,4,4,5,5,5,5,100]]
bb=pd.DataFrame(aa)
min=np.percentile(bb,1,axis=1,interpolation=‘higher’)
max=np.percentile(bb,99,axis=1,interpolation=‘higher’)
1,99 是索引的比例位置
higher lower,是取索引的小值还是大值

官方文档入口:https://docs.scipy.org/doc/numpy/reference/generated/numpy.percentile.html

np.percentile函数是numpy库中的一个函数,用于计算数组中指定百分位数的。它的语法格式为:np.percentile(a, q, axis=None, out=None, overwrite_input=False, interpolation='linear', keepdims=False)。其中,a是用来计算分位数的数组,q是一个介于0-100之间的浮点数,表示要计算分位数。这个函数可以计算多维数组的分位数,并且可以指定计算的轴。 举个例子,假设我们有一个数组a = np.array([[10, 7, 4], [3, 2, 1]]),我们可以使用np.percentile函数计算该数组的50%分位数,即中位数。np.percentile(a, 50)的结果是3.5。如果我们指定axis=0,表示按列计算分位数np.percentile(a, 50, axis=0)的结果是[[6.5, 4.5, 2.5]]。如果我们指定axis=1,表示按行计算分位数np.percentile(a, 50, axis=1)的结果是[7., 2.]。如果我们还想保持维度信息,可以设置keepdims=True,np.percentile(a, 50, axis=1, keepdims=True)的结果是[[7.], [2.]]。 总之,np.percentile函数是一个非常有用的函数,可以用来计算数组中的分位数,灵活性很高,可以满足各种计算需求。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [np.percentile()函数详解](https://blog.csdn.net/weixin_40845358/article/details/84638449)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* [np.percentile()函数解析](https://download.csdn.net/download/weixin_38602982/14858146)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值