bottleneck 1.6.0


pip install bottleneck

  Latest version

Released: Sep 08, 2025

Project Links

Meta
Maintainer: Christopher Whelan
Requires Python: >=3.10

Classifiers

Development Status
  • 5 - Production/Stable

Environment
  • Console

Intended Audience
  • Science/Research
  • Financial and Insurance Industry

Operating System
  • OS Independent

Programming Language
  • C
  • Python
  • Python :: 3
  • Python :: 3.10
  • Python :: 3.11
  • Python :: 3.12
  • Python :: 3.13
  • Python :: 3.14
  • Python :: Free Threading :: 2 - Beta

Topic
  • Scientific/Engineering

Bottleneck is a collection of fast NumPy array functions written in C.

Let’s give it a try. Create a NumPy array:

>>> import numpy as np
>>> a = np.array([1, 2, np.nan, 4, 5])

Find the nanmean:

>>> import bottleneck as bn
>>> bn.nanmean(a)
3.0

Moving window mean:

>>> bn.move_mean(a, window=2, min_count=1)
array([ 1. ,  1.5,  2. ,  4. ,  4.5])

Benchmark

Bottleneck comes with a benchmark suite:

>>> bn.bench()
Bottleneck performance benchmark
    Bottleneck 1.3.0.dev0+122.gb1615d7; Numpy 1.16.4
    Speed is NumPy time divided by Bottleneck time
    NaN means approx one-fifth NaNs; float64 used

              no NaN     no NaN      NaN       no NaN      NaN
               (100,)  (1000,1000)(1000,1000)(1000,1000)(1000,1000)
               axis=0     axis=0     axis=0     axis=1     axis=1
nansum         29.7        1.4        1.6        2.0        2.1
nanmean        99.0        2.0        1.8        3.2        2.5
nanstd        145.6        1.8        1.8        2.7        2.5
nanvar        138.4        1.8        1.8        2.8        2.5
nanmin         27.6        0.5        1.7        0.7        2.4
nanmax         26.6        0.6        1.6        0.7        2.5
median        120.6        1.3        4.9        1.1        5.7
nanmedian     117.8        5.0        5.7        4.8        5.5
ss             13.2        1.2        1.3        1.5        1.5
nanargmin      66.8        5.5        4.8        3.5        7.1
nanargmax      57.6        2.9        5.1        2.5        5.3
anynan         10.2        0.3       52.3        0.8       41.6
allnan         15.1      196.0      156.3      135.8      111.2
rankdata       45.9        1.2        1.2        2.1        2.1
nanrankdata    50.5        1.4        1.3        2.4        2.3
partition       3.3        1.1        1.6        1.0        1.5
argpartition    3.4        1.2        1.5        1.1        1.6
replace         9.0        1.5        1.5        1.5        1.5
push         1565.6        5.9        7.0       13.0       10.9
move_sum     2159.3       31.1       83.6      186.9      182.5
move_mean    6264.3       66.2      111.9      361.1      246.5
move_std     8653.6       86.5      163.7      232.0      317.7
move_var     8856.0       96.3      171.6      267.9      332.9
move_min     1186.6       13.4       30.9       23.5       45.0
move_max     1188.0       14.6       29.9       23.5       46.0
move_argmin  2568.3       33.3       61.0       49.2       86.8
move_argmax  2475.8       30.9       58.6       45.0       82.8
move_median  2236.9      153.9      151.4      171.3      166.9
move_rank     847.1        1.2        1.4        2.3        2.6

You can also run a detailed benchmark for a single function using, for example, the command:

>>> bn.bench_detailed("move_median", fraction_nan=0.3)

Only arrays with data type (dtype) int32, int64, float32, and float64 are accelerated. All other dtypes result in calls to slower, unaccelerated functions. In the rare case of a byte-swapped input array (e.g. a big-endian array on a little-endian operating system) the function will not be accelerated regardless of dtype.

Where

download

https://pypi.python.org/pypi/Bottleneck

docs

https://bottleneck.readthedocs.io

code

https://github.com/pydata/bottleneck

mailing list

https://groups.google.com/group/bottle-neck

License

Bottleneck is distributed under a Simplified BSD license. See the LICENSE file and LICENSES directory for details.

Install

Bottleneck provides binary wheels on PyPI for all the most common platforms. Binary packages are also available in conda-forge. We recommend installing binaries with pip, uv, conda or similar - it’s faster and easier than building from source.

Installing from source

Requirements:

Bottleneck

Python >=3.9; NumPy 1.16.0+

Compile

gcc, clang, MinGW or MSVC

Unit tests

pytest

Documentation

sphinx, numpydoc

To install Bottleneck on Linux, Mac OS X, et al.:

$ pip install .

To install bottleneck on Windows, first install MinGW and add it to your system path. Then install Bottleneck with the command:

$ python setup.py install --compiler=mingw32

Unit tests

After you have installed Bottleneck, run the suite of unit tests:

In [1]: import bottleneck as bn

In [2]: bn.test()
============================= test session starts =============================
platform linux -- Python 3.7.4, pytest-4.3.1, py-1.8.0, pluggy-0.12.0
hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('/home/chris/code/bottleneck/.hypothesis/examples')
rootdir: /home/chris/code/bottleneck, inifile: setup.cfg
plugins: openfiles-0.3.2, remotedata-0.3.2, doctestplus-0.3.0, mock-1.10.4, forked-1.0.2, cov-2.7.1, hypothesis-4.32.2, xdist-1.26.1, arraydiff-0.3
collected 190 items

bottleneck/tests/input_modification_test.py ........................... [ 14%]
..                                                                      [ 15%]
bottleneck/tests/list_input_test.py .............................       [ 30%]
bottleneck/tests/move_test.py .................................         [ 47%]
bottleneck/tests/nonreduce_axis_test.py ....................            [ 58%]
bottleneck/tests/nonreduce_test.py ..........                           [ 63%]
bottleneck/tests/reduce_test.py ....................................... [ 84%]
............                                                            [ 90%]
bottleneck/tests/scalar_input_test.py ..................                [100%]

========================= 190 passed in 46.42 seconds =========================
Out[2]: True

If developing in the git repo, simply run py.test

1.6.0 Sep 08, 2025
1.6.0rc1 Sep 06, 2025
1.5.0 May 13, 2025
1.5.0rc1 May 12, 2025
1.4.2 Oct 18, 2024
1.4.2rc1 Oct 18, 2024
1.4.1 Oct 13, 2024
1.4.1rc3 Oct 13, 2024
1.4.1rc1 Oct 12, 2024
1.4.0 Jun 17, 2024
1.4.0rc6 Jun 17, 2024
1.4.0rc5 May 23, 2024
1.4.0rc4 May 04, 2024
1.3.8 Feb 25, 2024
1.3.8rc5 Feb 24, 2024
1.3.7 Mar 08, 2023
1.3.7rc1 Jan 20, 2023
1.3.6 Jan 20, 2023
1.3.6rc1 Jan 19, 2023
1.3.5 Jul 02, 2022
1.3.5rc2 Jul 02, 2022
1.3.5rc1 Jul 02, 2022
1.3.4 Feb 22, 2022
1.3.3 Feb 22, 2022
1.3.3rc14 Feb 22, 2022
1.3.3rc13 Feb 21, 2022
1.3.3rc12.post0.dev6 Feb 21, 2022
1.3.3rc12.post0.dev5 Feb 21, 2022
1.3.3rc12.post0.dev4 Feb 21, 2022
1.3.3rc12.post0.dev1 Feb 20, 2022
1.3.3rc2 Feb 20, 2022
1.3.2 Feb 21, 2020
1.3.1 Nov 19, 2019
1.3.0 Nov 13, 2019
1.3.0rc2 Nov 09, 2019
1.3.0rc1 Nov 03, 2019
1.2.1 May 15, 2017
1.2.0 Oct 20, 2016
1.1.0 Jun 22, 2016
1.0.0 Feb 06, 2015
0.8.0 Jan 21, 2014
0.7.0 Sep 10, 2013
0.6.0 Jun 04, 2012
0.5.0 Jun 13, 2011
0.4.3
0.4.2
0.4.1
0.4.0
0.3.0 Jan 20, 2011
0.2.0 Dec 27, 2010
0.1.0 Dec 01, 2010
0.1.0.dev0 Nov 28, 2010
0.4.3_64bitOS Mar 17, 2011
0.4.3_32bitOS Mar 17, 2011
0.4.2_64bitOS Mar 09, 2011
0.4.2_32bitOS Mar 09, 2011
0.4.1_64bitOS Mar 08, 2011
0.4.1_32bitOS Mar 08, 2011
0.4.0_64bitOS Mar 08, 2011
0.4.0_32bitOS Mar 08, 2011

Wheel compatibility matrix

Platform CPython 3.10 CPython 3.11 CPython 3.12 CPython 3.13 CPython 3.14 CPython (additional flags: t) 3.13 CPython (additional flags: t) 3.14
macosx_11_0_arm64
manylinux1_x86_64
manylinux2014_aarch64
manylinux_2_17_aarch64
manylinux_2_28_aarch64
manylinux_2_28_x86_64
manylinux_2_5_x86_64
musllinux_1_2_aarch64
musllinux_1_2_x86_64
win32
win_amd64

Files in release

bottleneck-1.6.0-cp310-cp310-macosx_11_0_arm64.whl (98.0KiB)
bottleneck-1.6.0-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (362.8KiB)
bottleneck-1.6.0-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (355.0KiB)
bottleneck-1.6.0-cp310-cp310-musllinux_1_2_aarch64.whl (348.8KiB)
bottleneck-1.6.0-cp310-cp310-musllinux_1_2_x86_64.whl (359.0KiB)
bottleneck-1.6.0-cp310-cp310-win32.whl (105.3KiB)
bottleneck-1.6.0-cp310-cp310-win_amd64.whl (110.7KiB)
bottleneck-1.6.0-cp311-cp311-macosx_11_0_arm64.whl (98.0KiB)
bottleneck-1.6.0-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (367.1KiB)
bottleneck-1.6.0-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (359.3KiB)
bottleneck-1.6.0-cp311-cp311-musllinux_1_2_aarch64.whl (352.9KiB)
bottleneck-1.6.0-cp311-cp311-musllinux_1_2_x86_64.whl (363.2KiB)
bottleneck-1.6.0-cp311-cp311-win32.whl (105.3KiB)
bottleneck-1.6.0-cp311-cp311-win_amd64.whl (110.7KiB)
bottleneck-1.6.0-cp312-cp312-macosx_11_0_arm64.whl (98.2KiB)
bottleneck-1.6.0-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (368.6KiB)
bottleneck-1.6.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (359.7KiB)
bottleneck-1.6.0-cp312-cp312-musllinux_1_2_aarch64.whl (352.8KiB)
bottleneck-1.6.0-cp312-cp312-musllinux_1_2_x86_64.whl (364.5KiB)
bottleneck-1.6.0-cp312-cp312-win32.whl (105.5KiB)
bottleneck-1.6.0-cp312-cp312-win_amd64.whl (110.8KiB)
bottleneck-1.6.0-cp313-cp313-macosx_11_0_arm64.whl (98.2KiB)
bottleneck-1.6.0-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (368.9KiB)
bottleneck-1.6.0-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (359.9KiB)
bottleneck-1.6.0-cp313-cp313-musllinux_1_2_aarch64.whl (353.0KiB)
bottleneck-1.6.0-cp313-cp313-musllinux_1_2_x86_64.whl (364.7KiB)
bottleneck-1.6.0-cp313-cp313-win32.whl (105.5KiB)
bottleneck-1.6.0-cp313-cp313-win_amd64.whl (110.8KiB)
bottleneck-1.6.0-cp313-cp313t-macosx_11_0_arm64.whl (99.2KiB)
bottleneck-1.6.0-cp313-cp313t-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (382.6KiB)
bottleneck-1.6.0-cp313-cp313t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (374.5KiB)
bottleneck-1.6.0-cp313-cp313t-musllinux_1_2_aarch64.whl (366.7KiB)
bottleneck-1.6.0-cp313-cp313t-musllinux_1_2_x86_64.whl (377.3KiB)
bottleneck-1.6.0-cp313-cp313t-win32.whl (106.9KiB)
bottleneck-1.6.0-cp313-cp313t-win_amd64.whl (112.5KiB)
bottleneck-1.6.0-cp314-cp314-macosx_11_0_arm64.whl (98.2KiB)
bottleneck-1.6.0-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (369.4KiB)
bottleneck-1.6.0-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (360.3KiB)
bottleneck-1.6.0-cp314-cp314-musllinux_1_2_aarch64.whl (353.6KiB)
bottleneck-1.6.0-cp314-cp314-musllinux_1_2_x86_64.whl (365.3KiB)
bottleneck-1.6.0-cp314-cp314-win32.whl (107.6KiB)
bottleneck-1.6.0-cp314-cp314-win_amd64.whl (113.2KiB)
bottleneck-1.6.0-cp314-cp314t-macosx_11_0_arm64.whl (99.2KiB)
bottleneck-1.6.0-cp314-cp314t-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (383.2KiB)
bottleneck-1.6.0-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (375.0KiB)
bottleneck-1.6.0-cp314-cp314t-musllinux_1_2_aarch64.whl (367.2KiB)
bottleneck-1.6.0-cp314-cp314t-musllinux_1_2_x86_64.whl (377.8KiB)
bottleneck-1.6.0-cp314-cp314t-win32.whl (109.0KiB)
bottleneck-1.6.0-cp314-cp314t-win_amd64.whl (114.9KiB)
bottleneck-1.6.0.tar.gz (101.9KiB)
Extras:
Dependencies:
numpy