Bootstrapping with Pandas made easy
Project description
Pandas Bootstrap
Bootrapping with Pandas made easy.
Installation
pip install pandas-bootstrap
Usage
The module is very easy to use.
import bootstrap
- define statistic function:
def some_func(df: pd.DataFrame | pd.Series):
- get bootstrapped samples:
df.boot.get_samples(bfunc=some_func, B=100)
Below is a simple example of bootstrapping the mean of two columns.
import pandas as pd
import bootstrap
df = pd.DataFrame({
'a': [1, 2, 3, 4, 5],
'b': [6, 7, 8, 9, 10],
})
def mean_of_columns(df):
return df.mean(numeric_only=True)
sample_kwargs = dict(random_state=42)
df_bootstrap = df.boot.get_samples(bfunc=mean_of_columns, B=5, sample_kwargs=sample_kwargs)
which results in:
a b
sample
0 3.0 8.0
1 2.6 7.6
2 4.0 9.0
3 3.2 8.2
4 3.0 8.0
Documentation
Read more in the documentation
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pandas_bootstrap-0.1.1.tar.gz
(3.9 kB
view hashes)
Built Distribution
Close
Hashes for pandas_bootstrap-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 44f9d909a338aa55e69fadfcdc08fc7b31dfcef58d17c56743649f5c2167bace |
|
MD5 | ea824ff894b030ed81dac0a97cfbf753 |
|
BLAKE2b-256 | 0505394123028b141eacde15c2f8f9dc8b49ebcc5699dc4e1e7165c997455bd4 |