pyinterp.Binning1D

Contents

pyinterp.Binning1D#

pyinterp.Binning1D(x: pyinterp.core.Axis, range: tuple[float, float] | None = None, dtype: object | None = None) object#

Create a 1D binning for grouping values into bins on a vector.

Group a number of more or less continuous values into a smaller number of “bins” located on a vector.

Parameters:
  • x – Definition of the bin centers for the X Axis.

  • range – Range of the binning. If not provided, range is simply (x.min_value(), x.max_value()).

  • dtype – Data type for internal storage, either ‘float32’ or ‘float64’. Determines precision and memory usage. Defaults to ‘float64’.

Examples

>>> import pyinterp
>>> import numpy as np
>>> x = pyinterp.Axis(np.arange(0, 10, 0.1))
>>> binning = pyinterp.Binning1D(x)

Create with float32 for reduced memory usage

>>> binning = pyinterp.Binning1D(x, dtype='float32')
Returns:

Binning1D instance with the specified dtype. Statistical methods return 1D numpy arrays instead of 2D arrays.