Statistics in Python
Commonly Used Functions for Analysis,
Testing and Interpretation
Pooja Pawar
Descriptive Statistics
mean() → Calculates the average value
Example: [Link](data)
median() → Finds the middle value
Example: [Link](data)
mode() → Identifies the most frequent value
Example: [Link](data)
sum() → Adds all values
Example: [Link](data)
min() → Returns the smallest value
Example: [Link](data)
max() → Returns the largest value
Example: [Link](data)
ptp() → Calculates range (max − min)
Example: [Link](data)
Pooja Pawar
Variability & Dispersion
var() → Measures variance
Example: [Link](data)
std() → Measures standard deviation
Example: [Link](data)
iqr() → Interquartile range
Example: [Link](data)
percentile() → Percentile-based value
Example: [Link](data, 75)
quantile() → Quantile calculation
Example: [Link](data, 0.25)
median_abs_deviation() → Robust dispersion
Example: stats.median_abs_deviation(data)
sem() → Standard error of mean
Example: [Link](data)
Pooja Pawar
Distribution Shape &
Summary
skew() → Measures asymmetry
Example: [Link](data)
kurtosis() → Measures tail heaviness
Example: [Link](data)
describe() → Summary statistics
Example: [Link](data)
histogram() → Frequency distribution
Example: [Link](data)
bincount() → Counts discrete occurrences
Example: [Link](data)
unique() → Finds unique values
Example: [Link](data)
count_nonzero() → Counts non-zero values
Example: np.count_nonzero(data) Pooja Pawar
Normality & Distribution
Tests
normaltest() → Tests normal distribution
Example: [Link](data)
shapiro() → Shapiro-Wilk test
Example: [Link](data)
jarque_bera() → Normality via skew & kurtosis
Example: stats.jarque_bera(data)
kstest() → Compares sample with distribution
Example: [Link](data, 'norm')
anderson() → Anderson-Darling test
Example: [Link](data)
norm() → Normal distribution object
Example: [Link]()
uniform() → Uniform distribution
Example: [Link]() Pooja Pawar
Correlation &
Association
corrcoef() → Correlation matrix
Example: [Link](x, y)
pearsonr() → Linear correlation
Example: [Link](x, y)
spearmanr() → Rank correlation
Example: [Link](x, y)
kendalltau() → Ordinal association
Example: [Link](x, y)
cov() → Covariance matrix
Example: [Link](x, y)
corr() → Pairwise correlation (pandas)
Example: [Link]()
autocorr() → Self-correlation
Example: [Link]() Pooja Pawar
Hypothesis Testing
ttest_1samp() → One-sample t-test
Example: stats.ttest_1samp(data, mu)
ttest_ind() → Independent samples t-test
Example: stats.ttest_ind(a, b)
ttest_rel() → Paired t-test
Example: stats.ttest_rel(a, b)
f_oneway() → One-way ANOVA
Example: stats.f_oneway(a, b, c)
levene() → Equality of variances
Example: [Link](a, b)
bartlett() → Homogeneity of variance
Example: [Link](a, b)
ttest_ind_from_stats() → T-test using summary
stats
Example: stats.ttest_ind_from_stats(...) Pooja Pawar
Non-Parametric Tests
mannwhitneyu() → Non-parametric two-sample
test
Example: [Link](a, b)
wilcoxon() → Paired non-parametric test
Example: [Link](a, b)
kruskal() → Non-parametric ANOVA
Example: [Link](a, b, c)
friedmanchisquare() → Repeated measures test
Example: [Link](a, b, c)
rankdata() → Assigns ranks
Example: [Link](data)
median_test() → Compares medians
Example: stats.median_test(a, b)
ks_2samp() → Two-sample KS test
Example: stats.ks_2samp(a, b) Pooja Pawar
Probability Distributions
binom() → Binomial distribution
Example: [Link](n, p)
poisson() → Poisson distribution
Example: [Link](mu)
expon() → Exponential distribution
Example: [Link]()
chi2() → Chi-square distribution
Example: stats.chi2(df)
t() → Student’s t distribution
Example: stats.t(df)
lognorm() → Log-normal distribution
Example: [Link](s)
gamma() → Gamma distribution
Example: [Link](a)
Pooja Pawar
Regression, Resampling
& Utilities
linregress() → Linear regression stats
Example: [Link](x, y)
zscore() → Standard score normalization
Example: [Link](data)
bootstrap() → Resampling technique
Example: [Link](data)
trim_mean() → Mean after trimming extremes
Example: stats.trim_mean(data, 0.1)
winsorize() → Limits extreme values
Example: [Link](data)
bayes_mvs() → Bayesian estimates
Example: stats.bayes_mvs(data)
describe() (pandas) → Dataset-wide stats
Example: [Link]() Pooja Pawar
Advanced Statistical
Functions
entropy() → Measures uncertainty in a dataset
Example: [Link](data)
gmean() → Calculates geometric mean
Example: [Link](data)
hmean() → Calculates harmonic mean
Example: [Link](data)
variation() → Coefficient of variation
Example: [Link](data)
trim_mean() → Mean after trimming extreme values
Example: stats.trim_mean(data, 0.1)
winsorize() → Limits the effect of outliers
Example: [Link](data)
rankdata() → Assigns ranks to values
Example: [Link](data) Pooja Pawar
Follow for more
data analytics
content
Pooja Pawar