Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wd60622/pandas-bootstrap
Statistical Bootstrap in Pandas
https://github.com/wd60622/pandas-bootstrap
bootstrap data-science pandas python statistical-analysis statistics
Last synced: 3 months ago
JSON representation
Statistical Bootstrap in Pandas
- Host: GitHub
- URL: https://github.com/wd60622/pandas-bootstrap
- Owner: wd60622
- License: mit
- Created: 2023-07-10T17:46:45.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-03-17T17:30:26.000Z (10 months ago)
- Last Synced: 2024-09-19T18:07:33.992Z (3 months ago)
- Topics: bootstrap, data-science, pandas, python, statistical-analysis, statistics
- Language: Python
- Homepage: https://wd60622.github.io/pandas-bootstrap/
- Size: 3.21 MB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Pandas Bootstrap
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![Tests](https://github.com/wd60622/pandas-bootstrap/actions/workflows/tests.yml/badge.svg)](https://github.com/wd60622/pandas-bootstrap/actions/workflows/tests.yml)
[![PyPI version](https://badge.fury.io/py/pandas-bootstrap.svg)](https://badge.fury.io/py/pandas-bootstrap)
[![docs](https://github.com/wd60622/pandas-bootstrap/actions/workflows/docs.yml/badge.svg)](https://wd60622.github.io/pandas-bootstrap/)
[![codecov](https://codecov.io/gh/wd60622/pandas-bootstrap/graph/badge.svg?token=WEJBSBMTYN)](https://codecov.io/gh/wd60622/pandas-bootstrap)Statistical Bootstrap with Pandas made easy.
## Installation
```bash
pip install pandas-bootstrap
```## Usage
The module is very easy to use.
1. `import bootstrap`
2. define statistic function: `def some_func(df: pd.DataFrame | pd.Series):`
3. get bootstrapped samples: `df.boot.get_samples(bfunc=some_func, B=100)`Below is a simple example of bootstrapping the mean of two columns.
```python
import pandas as pdimport 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:
```text
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](https://wd60622.github.io/pandas-bootstrap/)