physt.compat package

Submodules

physt.compat.dask module

Dask-based and dask oriented variants of physt histogram facade functions.

physt.compat.dask.h1(data: Array | ArrayLike, bins: Any = None, *, compute: bool = True, **kwargs)

Facade function to create one-dimensional histogram using dask.

Parameters:

data (dask.DaskArray or array-like (can have more than one dimension))

See also

physt.histogram

physt.compat.dask.h2(data1, data2, bins=None, **kwargs)

Facade function to create 2D histogram using dask.

physt.compat.dask.h3(data, bins=None, **kwargs)

Facade function to create 3D histogram using dask.

physt.compat.dask.histogram1d(data: Array | ArrayLike, bins: Any = None, *, compute: bool = True, **kwargs)

Facade function to create one-dimensional histogram using dask.

Parameters:

data (dask.DaskArray or array-like (can have more than one dimension))

See also

physt.histogram

physt.compat.dask.histogram2d(data1, data2, bins=None, **kwargs)

Facade function to create 2D histogram using dask.

physt.compat.dask.histogramdd(data: Array | ArrayLike, bins: Any = None, **kwargs)

Facade function to create multi-dimensional histogram using dask.

Each “column” must be one-dimensional.

physt.compat.geant4 module

Support for Geant4 histograms saved in CSV format.

See https://geant4.web.cern.ch/ for the project pages.

physt.compat.geant4.load_csv(path: str) Histogram1D | Histogram2D

Loads a histogram as output from Geant4 analysis tools in CSV format.

Parameters:

path (str) – Path to the CSV file

Return type:

physt.histogram1d.Histogram1D or physt.histogram_nd.Histogram2D

physt.compat.pandas module

Pandas integration.

  • conversion between histograms and Series/DataFrames

  • .physt accessor for pandas objects

class physt.compat.pandas.PhystDataFrameAccessor(df: DataFrame)

Bases: object

Histogramming methods for pandas DataFrames.

h1(column: Any = None, bins=None, *, weights: ArrayLike | str | None = None, **kwargs) Histogram1D

Create 1D histogram from a column.

Parameters:
  • column (Name of the column to apply on (not required for 1-column data frames))

  • bins (Universal bins argument)

  • weights (Name of the column to use for weight or some arraylike object)

See also

physt.h1

h2(column1: Any = None, column2: Any = None, bins=None, **kwargs) Histogram2D

Create 2D histogram from two columns.

Parameters:
  • column1 (Name of the first column (not required for 2-column data frames))

  • column2 (Name of the second column (not required for 2-column data frames))

  • bins (Universal bins argument)

  • dropna (Ignore NA values)

See also

physt.h2

histogram(columns: Any = None, bins: Any = None, **kwargs) HistogramND

Create a histogram.

Parameters:
  • columns (The column(s) to apply on. Uses all columns if not set. It can be) – a str for one column, tuple for a multi-level index, list for more columns, everything that pandas item selection supports.

  • bins (Argument to be passed to find the proper binnings.)

Return type:

A histogram with dimensionality depending on the final set of columns.

See also

physt.h

class physt.compat.pandas.PhystSeriesAccessor(series: Series)

Bases: object

Histogramming methods for pandas Series.

It exists only for numeric series.

cut(bins=None, **kwargs) Series

Bin values using physt binning (eq. to pd.cut).

h1(bins=None, **kwargs) Histogram1D

Create a histogram from the series.

histogram(bins=None, **kwargs) Histogram1D

Create a histogram from the series.

physt.compat.pandas.binning_to_index(binning: BinningBase, name: str | None = None) IntervalIndex

Convert physt binning to a pandas interval index.

physt.compat.pandas.index_to_binning(index: IntervalIndex) BinningBase

Convert an interval index into physt binning.

Module contents

Histograms types and function for various external libraries.