Skip to main content
https://travis-ci.org/tinybike/weightedstats.svg?branch=master https://coveralls.io/repos/github/tinybike/weightedstats/badge.svg?branch=master:target:https://coveralls.io/github/tinybike/weightedstats?branch=master https://badge.fury.io/py/weightedstats.svg

Python functions to calculate the mean, weighted mean, median, and weighted median.

Installation

The easiest way to install WeightedStats is to use pip:

$ pip install weightedstats

Usage

WeightedStats includes four functions (mean, weighted_mean, median, weighted_median) which accept lists as arguments, and two functions (numpy_weighted_mean, numpy weighted_median) which accept either lists or numpy arrays.

Example:

import weightedstats as ws

my_data = [1, 2, 3, 4, 5]
my_weights = [10, 1, 1, 1, 9]

# Ordinary (unweighted) mean and median
ws.mean(my_data)    # equivalent to ws.weighted_mean(my_data)
ws.median(my_data)  # equivalent to ws.weighted_median(my_data)

# Weighted mean and median
ws.weighted_mean(my_data, weights=my_weights)
ws.weighted_median(my_data, weights=my_weights)

# Special weighted mean and median functions for use with numpy arrays
ws.numpy_weighted_mean(my_data, weights=my_weights)
ws.numpy_weighted_median(my_data, weights=my_weights)

Tests

Unit tests are in the test/ directory.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

weightedstats-0.4.1.tar.gz (4.3 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

weightedstats-0.4.1-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

weightedstats-0.4.1-py2-none-any.whl (3.8 kB view details)

Uploaded Python 2

File details

Details for the file weightedstats-0.4.1.tar.gz.

File metadata

  • Download URL: weightedstats-0.4.1.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/2.7.17

File hashes

Hashes for weightedstats-0.4.1.tar.gz
Algorithm Hash digest
SHA256 beb488a3f46aa06dbc8491578ec7e408847ca682edc7ec90846f6df9e36cab50
MD5 f5cac13564b15e49a4eee9ca6d195ca4
BLAKE2b-256 daa5f5c0e601a610e4618316be3155febbbec98994788fcc0e9d8080369266ec

See more details on using hashes here.

File details

Details for the file weightedstats-0.4.1-py3-none-any.whl.

File metadata

  • Download URL: weightedstats-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 3.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/2.7.17

File hashes

Hashes for weightedstats-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6ead0c27df10b0598d7e3a1c2bc201b925f5ac47099df0dafccce91932a5d155
MD5 9fd33eb4e0fd37ae53013243deee3c8b
BLAKE2b-256 8d7324ecd3d2230edb304d8c2febe61711ae75c11fc792acc8fd3b056b4eb6cc

See more details on using hashes here.

File details

Details for the file weightedstats-0.4.1-py2-none-any.whl.

File metadata

  • Download URL: weightedstats-0.4.1-py2-none-any.whl
  • Upload date:
  • Size: 3.8 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/2.7.17

File hashes

Hashes for weightedstats-0.4.1-py2-none-any.whl
Algorithm Hash digest
SHA256 5633991d01864dca581816da3070eed95fb3671020937a8dbad7afab4a38ef0c
MD5 83020234e29603d365fa7f584c684cbf
BLAKE2b-256 4ac7bd3aea4766db65f7da86753450c80a786bddbb2a11db2f9667376ec14910

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.4.1 This release

3 files

0.4

3 files

0.3

1 file

0.2

1 file

0.1

1 file

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page