Introduction

Setup

Operators

variable

String

Number

Dtype & Comment

Lists

Tuples

Sets

Dictionaries

if else statement

For Loop

While Loop

iterator & iterable

Pre-Built functions

Function

Decorators

Generators

Types of errors

Exceptions Handling

OOP

Regular expression

Create module

OS module

Date module

Random module

Math

Statistics module

Exercise 1

Exercise 2

Exercise 3

Learn Data Structure & Algorithm

Learn Numpy

Learn Pandas

Learn Matplotlib

Learn Seaborn

Learn Statistics

Learn Math

Learn MATLAB

Learn Machine learning

Learn Github

Learn OpenCV

Learn Deep Learning

Learn MySQL

Learn MongoDB

Learn Web scraping

Learn Excel

Learn Power BI

Learn Tableau

Learn Docker

Learn Hadoop

Python statistics module

What is statistics module?

In python, we get a build-in module to calculate numerical data of statistics. It provides a lot of functions to perform statistics. Here we get functions from basic to advance.
Suppose need to calculate mean, median mode, standard deviation or correlation between two list, etc. We can easily perform those by using statistics module.

Statistics module methods


Methods Description
statistics.median_grouped() This method is used to calculate the median of grouped continuous data
statistics.median() This method is used to calculate the median of the given data
statistics.stdev() This method is used to calculates the standard deviation from a sample of data
statistics.variance() This method is used to calculate the variance from a sample of data
statistics.pstdev() This method is used to calculate the standard deviation from an entire population
statistics.harmonic_mean() This method is used to calculate the harmonic mean of the given data
statistics.pvariance() This method is used to calculate the variance of an entire population
statistics.median_high() This method is used to calculate the high median of the given data
statistics.median_low() This method is used to calculate the low median of the given data
statistics.mean() This method is used to calculate the mean of the given data
statistics.mode() This method is used to calculate the mode of the given numeric or nominal data

Example:1
Input
import statistics

print(statistics.mean([10, 3, 9, 7, 9, 16, 13]))
print(statistics.mean([1, 33, 5, 0, 9, 21]))
print(statistics.mean([1, -5, -1.9, 7.1, 19, -12]))
Output
9.571428571428571
11.5
1.3666666666666667
Example:2
Input
import statistics

print(statistics.mode([1, 2, 3, 5, 9, 8, 9]))
print(statistics.mode([1, 3, -1, 2, 5, -19]))
print(statistics.mode(['ticket', 'gadget', 'car', 'mobile']))
Output
9
1
ticket
Example:3
Input
import statistics

print(statistics.variance([6, 3, 9, 7, 4, 11]))
print(statistics.variance([1, 7.44, 1.25, 4.75, 1.9]))
print(statistics.variance([-21, -8.5, 6.4, 8.7]))
print(statistics.variance([1, 40, 20, 90]))
Output
9.066666666666666
7.672370000000002
192.68666666666664
1466.9166666666667

CodersAim is created for learning and training a self learner to become a professional from beginner. While using CodersAim, you agree to have read and accepted our terms of use, privacy policy, Contact Us

© Copyright All rights reserved www.CodersAim.com. Developed by CodersAim.