Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

calculate percentile pandas dataframe

import pandas as pd
import random

A = [ random.randint(0,100) for i in range(10) ]
B = [ random.randint(0,100) for i in range(10) ]

df = pd.DataFrame({ 'field_A': A, 'field_B': B })
df
#    field_A  field_B
# 0       90       72
# 1       63       84
# 2       11       74
# 3       61       66
# 4       78       80
# 5       67       75
# 6       89       47
# 7       12       22
# 8       43        5
# 9       30       64

df.field_A.mean()   # Same as df['field_A'].mean()
# 54.399999999999999

df.field_A.median() 
# 62.0

# You can call `quantile(i)` to get the i'th quantile,
# where `i` should be a fractional number.

df.field_A.quantile(0.1) # 10th percentile
# 11.9

df.field_A.quantile(0.5) # same as median
# 62.0

df.field_A.quantile(0.9) # 90th percentile
# 89.10000000000001
Comment

calculate values in a certain percentile pandas

# Calculate the minimum number of votes required to be in the chart, m
m = metadata['vote_count'].quantile(0.90)
print(m)
Comment

PREVIOUS NEXT
Code Example
Python :: checking time in time range 
Python :: Python - Common Conditional Statements 
Python :: python basic programs quadratic equation 
Python :: python file operation 
Python :: python long multiline text 
Python :: python Access both key and value using iteritems() Return keys or values explicitly 
Python :: Abstract Model inherit from another model django 
Python :: the rest of steps in the link below 
Python :: convert python code to dart online 
Python :: Django forms I cannot save picture file 
Python :: frontmost flag qt 
Python :: django multi column index 
Python :: reopen closed file python 
Python :: datetime day deutsch python 
Python :: voting classifier grid search 
Python :: pyspark mapreduce dataframe 
Python :: odoo wizard current user login 
Python :: load pandas dataframe with one row per line and 1 column no delimiter 
Python :: pymol load coords 
Python :: print class name python 
Python :: enregistremen en pythin picklr 
Python :: scapy get packet destination port python 
Python :: numpy subtraction operation using numpy functions 
Python :: pypi cryptography 
Python :: code converter html 
Python :: python list as stacks 
Python :: get list values in b/w indexes python 
Python :: django chain query 
Python :: how to calculate the area and perimeter of a shape in python 
Python :: Como hacer mayusculas un string 
ADD CONTENT
Topic
Content
Source link
Name
7+6 =