Change language

sciPy function stats.scoreatpercentile () | python

The score at percentile = 50 is the median. If the required quantile lies between two data points, we interpolate them among ourselves according to the interpolation value.

Parameters:
arr: [array_like] input array.
per: [array_like] Percentile at which we need the score.
limit: [tuple] the lower and upper limits within which to compute the percentile.
axis: [int] axis along which we need to calculate the score.

Results: Score at Percentile relative to the array element.

Code # 1:

# scoreatpercentile

from scipy import stats

import nump y as np 

 
# 1D array

arr = [ 20 , 2 , 7 , 1 , 7 , 7 , 34 , 3 ]

 

print ( "arr:" , arr) 

 

print ( "Score at 50th percentile: "

  stats .scoreatpercentile (arr, 50 ))

 

print ( " Score at 90th percentile: "

  stats .scoreatpercentile (arr, 90 ))

 

print ( " Score at 10th percentile: "

  stats .scoreatpercentile (arr, 10 ))

 

< p> print ( "Score at 100th percentile:"

stats.scoreatpercentile (arr, 100 ))

 

print ( "Score at 30th percentile:"

stats.scoreatpercentile (arr, 30 ))

Exit :

 arr: [20, 2, 7, 1, 7, 7, 34, 3] Score at 50th percentile: 7.0 Score at 90th percentile: 24.2 Score at 10th percentile: 1.7 Score at 100th percentile: 34.0 Score at 30th percentile: 3.4 

Code # 2:

 

# scoreatpercentile

from scipy import stats

import numpy as np 

 

arr = [[ 14 , 17 , 12 , 33 , 44 ], 

[ 15 , 6 ,  27 , 8 , 19 ], 

  [ 23 , 2 , 54 , 1 , 4 ,]] 

  

print ( " arr: " , arr) 

  

print ( "Score at 50th percentile:"

stats.scoreatpercentile ( arr, 50 ))

 

print ( "Score at 50th percentile: "

  stats.scoreatpercentile ( arr, 50 , axis = 1 ))

 

print ( "Score at 50th percentile:"

  stats.scoreatpercentile (arr, 50 , axis = 0 ))

Exit:

 arr: [[14, 17, 12, 33, 44], [15 , 6, 27, 8, 19], [23, 2, 54, 1, 4]] Score at 50th percentile: 15.0 Score at 50th percentile: [17. 15. 4.] Score at 50th percentile: [15. 6 . 27. 8. 19.] 

Shop

Gifts for programmers

Learn programming in R: courses

$FREE
Gifts for programmers

Best Python online courses for 2022

$FREE
Gifts for programmers

Best laptop for Fortnite

$399+
Gifts for programmers

Best laptop for Excel

$
Gifts for programmers

Best laptop for Solidworks

$399+
Gifts for programmers

Best laptop for Roblox

$399+
Gifts for programmers

Best computer for crypto mining

$499+
Gifts for programmers

Best laptop for Sims 4

$

Latest questions

PythonStackOverflow

Common xlabel/ylabel for matplotlib subplots

1947 answers

PythonStackOverflow

Check if one list is a subset of another in Python

1173 answers

PythonStackOverflow

How to specify multiple return types using type-hints

1002 answers

PythonStackOverflow

Printing words vertically in Python

909 answers

PythonStackOverflow

Python Extract words from a given string

798 answers

PythonStackOverflow

Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?

606 answers

PythonStackOverflow

Python os.path.join () method

384 answers

PythonStackOverflow

Flake8: Ignore specific warning for entire file

360 answers

News


Wiki

Python | How to copy data from one Excel sheet to another

Common xlabel/ylabel for matplotlib subplots

Check if one list is a subset of another in Python

How to specify multiple return types using type-hints

Printing words vertically in Python

Python Extract words from a given string

Cyclic redundancy check in Python

Finding mean, median, mode in Python without libraries

Python add suffix / add prefix to strings in a list

Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?

Python - Move item to the end of the list

Python - Print list vertically