https://github.com/felixpatzelt/binny
Python package for smart binning of one-dimensional data and calculating conditional expectation values.
https://github.com/felixpatzelt/binny
Last synced: 5 months ago
JSON representation
Python package for smart binning of one-dimensional data and calculating conditional expectation values.
- Host: GitHub
- URL: https://github.com/felixpatzelt/binny
- Owner: felixpatzelt
- License: mit
- Created: 2018-06-07T20:50:09.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2022-12-12T07:37:33.000Z (over 2 years ago)
- Last Synced: 2024-12-27T14:40:49.253Z (5 months ago)
- Language: Jupyter Notebook
- Homepage:
- Size: 115 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGELOG.rst
- License: LICENSE.txt
Awesome Lists containing this project
README
binny
=====Bin one-dimensional data and calculate conditional expectation values.
The main function is ``bin_df``, which accepts numpy-arrays or pandas Dataframes
as inputs. Bins in linear, logarithmic, or quantile space are created for the
independent variable. The dependent variable is then aggregated in these bins.Lots of options allow to customise the binning and aggregation, calculate
errors, etc.Examples
--------.. code:: ipython
%pylab
from binny import bin_df
x = randn(10**4)
y = x**2 + randn(10**4)
bin_df(y, by=x, bins=11).plot(marker='x')
# now plot the same data using bins containing an equal number of events
# (quantile bins)
bin_df(y, by=x, bins=11, space='q').plot(marker='+')More examples can be found `in the notebooks directory `_.
Use `nbviewer `_ if GitHub fails to render.Installation
------------pip install binny
Dependencies
------------- Python >= 2.7 or >= 3.6
- NumPy
- Pandas