filmov
tv
Quantile in Python (4 Examples) | Calculate Quartile, Decile & Percentile of List & DataFrame Column
Показать описание
Python code of this video:
my_list = [8, 4, 4, 3, 2, 4, 1, 3, 5, 2, 1, 3, 7] # Create example list
print(my_list) # Print example list
# [8, 4, 4, 3, 2, 4, 1, 3, 5, 2, 1, 3, 7]
import numpy as np # Load NumPy library
# [2. 3. 4.]
# [1.2 2. 2.6 3. 3. 4. 4. 4.6 6.6]
# [1. 1. 1. 1. 1. 1. 1. 1. 1.08 1.2 1.32 1.44 1.56 1.68
# 1.8 1.92 2. 2. 2. 2. 2. 2. 2. 2. 2. 2.12 2.24 2.36
# 2.48 2.6 2.72 2.84 2.96 3. 3. 3. 3. 3. 3. 3. 3. 3.
# 3. 3. 3. 3. 3. 3. 3. 3. 3.12 3.24 3.36 3.48 3.6 3.72
# 3.84 3.96 4. 4. 4. 4. 4. 4. 4. 4. 4. 4. 4. 4.
# 4. 4. 4. 4. 4. 4.12 4.24 4.36 4.48 4.6 4.72 4.84 4.96 5.16
# 5.4 5.64 5.88 6.12 6.36 6.6 6.84 7.04 7.16 7.28 7.4 7.52 7.64 7.76
# 7.88]
import pandas as pd # Load pandas library
data = pd.DataFrame({'x1':[6, 2, 7, 3, 1, 4, 3, 4, 8, 7, 5], # Create pandas DataFrame
'x2':range(10, 21),
'group':['A', 'B', 'B', 'C', 'A', 'B', 'A', 'C', 'B', 'B', 'A']})
print(data) # Print pandas DataFrame
# 0.25 3.0
# 0.50 4.0
# 0.75 6.5
# Name: x1, dtype: float64
# 0.1 2.0
# 0.2 3.0
# 0.3 3.0
# 0.4 4.0
# 0.5 4.0
# 0.6 5.0
# 0.7 6.0
# 0.8 7.0
# 0.9 7.0
# Name: x1, dtype: float64
# 0.01 1.1
# 0.02 1.2
# 0.03 1.3
# 0.04 1.4
# 0.05 1.5
# x1 x2
# 0.25 3.0 12.5
# 0.50 4.0 15.0
# 0.75 6.5 17.5
# x1 x2
# group
# A 2.50 13.0
# B 4.00 12.0
# C 3.25 14.0
Follow me on Social Media:
my_list = [8, 4, 4, 3, 2, 4, 1, 3, 5, 2, 1, 3, 7] # Create example list
print(my_list) # Print example list
# [8, 4, 4, 3, 2, 4, 1, 3, 5, 2, 1, 3, 7]
import numpy as np # Load NumPy library
# [2. 3. 4.]
# [1.2 2. 2.6 3. 3. 4. 4. 4.6 6.6]
# [1. 1. 1. 1. 1. 1. 1. 1. 1.08 1.2 1.32 1.44 1.56 1.68
# 1.8 1.92 2. 2. 2. 2. 2. 2. 2. 2. 2. 2.12 2.24 2.36
# 2.48 2.6 2.72 2.84 2.96 3. 3. 3. 3. 3. 3. 3. 3. 3.
# 3. 3. 3. 3. 3. 3. 3. 3. 3.12 3.24 3.36 3.48 3.6 3.72
# 3.84 3.96 4. 4. 4. 4. 4. 4. 4. 4. 4. 4. 4. 4.
# 4. 4. 4. 4. 4. 4.12 4.24 4.36 4.48 4.6 4.72 4.84 4.96 5.16
# 5.4 5.64 5.88 6.12 6.36 6.6 6.84 7.04 7.16 7.28 7.4 7.52 7.64 7.76
# 7.88]
import pandas as pd # Load pandas library
data = pd.DataFrame({'x1':[6, 2, 7, 3, 1, 4, 3, 4, 8, 7, 5], # Create pandas DataFrame
'x2':range(10, 21),
'group':['A', 'B', 'B', 'C', 'A', 'B', 'A', 'C', 'B', 'B', 'A']})
print(data) # Print pandas DataFrame
# 0.25 3.0
# 0.50 4.0
# 0.75 6.5
# Name: x1, dtype: float64
# 0.1 2.0
# 0.2 3.0
# 0.3 3.0
# 0.4 4.0
# 0.5 4.0
# 0.6 5.0
# 0.7 6.0
# 0.8 7.0
# 0.9 7.0
# Name: x1, dtype: float64
# 0.01 1.1
# 0.02 1.2
# 0.03 1.3
# 0.04 1.4
# 0.05 1.5
# x1 x2
# 0.25 3.0 12.5
# 0.50 4.0 15.0
# 0.75 6.5 17.5
# x1 x2
# group
# A 2.50 13.0
# B 4.00 12.0
# C 3.25 14.0
Follow me on Social Media:
Комментарии