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.

Metadata

Release files for weightedstats 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for weightedstats 0.4.1
File Size Uploaded
weightedstats-0.4.1.tar.gz 4.3 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for weightedstats 0.4.1
File Interpreter ABI Platform
weightedstats-0.4.1-py3-none-any.whl Python 3 none any Details
weightedstats-0.4.1-py2-none-any.whl Python 2 none any Details

Total release size: 12.0 kB

Release files / weightedstats-0.4.1.tar.gz

Download URL weightedstats-0.4.1.tar.gz
Size 4.3 kB
Tags Source
SHA-256 checksum
How to use checksums
beb488a3f46aa06dbc8491578ec7e408847ca682edc7ec90846f6df9e36cab50
BLAKE2b-256 checksum
How to use checksums
daa5f5c0e601a610e4618316be3155febbbec98994788fcc0e9d8080369266ec
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / weightedstats-0.4.1-py3-none-any.whl

Download URL weightedstats-0.4.1-py3-none-any.whl
Size 3.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6ead0c27df10b0598d7e3a1c2bc201b925f5ac47099df0dafccce91932a5d155
BLAKE2b-256 checksum
How to use checksums
8d7324ecd3d2230edb304d8c2febe61711ae75c11fc792acc8fd3b056b4eb6cc
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / weightedstats-0.4.1-py2-none-any.whl

Download URL weightedstats-0.4.1-py2-none-any.whl
Size 3.8 kB
Tags Python 2
SHA-256 checksum
How to use checksums
5633991d01864dca581816da3070eed95fb3671020937a8dbad7afab4a38ef0c
BLAKE2b-256 checksum
How to use checksums
4ac7bd3aea4766db65f7da86753450c80a786bddbb2a11db2f9667376ec14910
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

0.4.1 This release

3 release files

0.4

3 release files

0.3

1 release file

0.2

1 release file

0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page