P(i/y)thon h(i/y)stograms. Inspired (and based on) numpy.histogram, but designed for humans(TM) on steroids(TM).
Create rich histogram objects from numpy or dask arrays, from pandas and polars series/dataframes, from xarray datasets and a few more types of objects. Manipulate them with ease, plot them with matplotlib, vega or plotly.
In short, whatever you want to do with histograms, physt aims to be on your side.
With uv
installed, you can run the following command without needing to install
anything to see some examples in action:
uv run --with "physt[terminal]>=0.8.3" -m physt.examples
from physt import h1
# Create the sample
heights = [160, 155, 156, 198, 177, 168, 191, 183, 184, 179, 178, 172, 173, 175,
172, 177, 176, 175, 174, 173, 174, 175, 177, 169, 168, 164, 175, 188,
178, 174, 173, 181, 185, 166, 162, 163, 171, 165, 180, 189, 166, 163,
172, 173, 174, 183, 184, 161, 162, 168, 169, 174, 176, 170, 169, 165]
hist = h1(heights, 10) # <--- get the histogram data
hist << 190 # <--- add a forgotten value
hist.plot() # <--- and plot it
from physt import h2
import seaborn as sns
iris = sns.load_dataset('iris')
iris_hist = h2(iris["sepal_length"], iris["sepal_width"], "pretty", bin_count=[12, 7], name="Iris")
iris_hist.plot(show_zero=False, cmap="gray_r", show_values=True);
import numpy as np
from physt import special_histograms
# Generate some sample data
data = np.empty((1000, 3))
data[:,0] = np.random.normal(0, 1, 1000)
data[:,1] = np.random.normal(0, 1.3, 1000)
data[:,2] = np.random.normal(1, .6, 1000)
# Get histogram data (in spherical coordinates)
h = special_histograms.spherical(data)
# And plot its projection on a globe
h.projection("theta", "phi").plot.globe_map(density=True, figsize=(7, 7), cmap="rainbow")
See more in docstring's and notebooks:
doc
directory.Using pip:
pip install physt
or conda:
conda install -c janpipek physt
seaborn
)rebin
(https://github.com/jhykes/rebin) with phystRationale (for both): physt is dumb, but precise.
Talk at PyData Berlin 2018:
I am looking for anyone interested in using / developing physt. You can contribute by reporting errors, implementing missing features and suggest new one.
Thanks to:
Patches: