bootstrap
Core bootstrapping logic which powers the boot
extension including parallelization and return type inference.
DataFrameFunction
Process a bootstrap function that returns a DataFrame.
Source code in bootstrap/bootstrap.py
SeriesFunction
Process a bootstrap function that returns a Series.
Source code in bootstrap/bootstrap.py
UnsupportedReturnType
bootstrap(bfunc_input, bfunc, B=100, sample_kwargs=None, parallel=None, **kwargs)
Core bootstrap function.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bfunc_input
|
BFUNC_INPUT
|
Input to bootstrap function. |
required |
bfunc
|
BFUNC
|
Bootstrap function. |
required |
B
|
int
|
Number of bootstrap samples. |
100
|
sample_kwargs
|
Optional[Dict[str, Any]]
|
Keyword arguments to pass to the sampling function. |
None
|
parallel
|
Optional[Parallel]
|
Parallelization object. |
None
|
**kwargs
|
kwargs
|
Keyword arguments to pass to the bootstrap function. |
{}
|
Returns:
Type | Description |
---|---|
Union[DataFrame, Series]
|
Bootstrap samples in a DataFrame or Series. |
Raises:
Type | Description |
---|---|
ValueError
|
If sample_kwargs contains 'replace' or 'frac' keys. |
UnsupportedReturnType
|
If the bootstrap function returns an unsupported type. |
Source code in bootstrap/bootstrap.py
get_bfunc_processor(return_type)
Get the appropriate bootstrap function processor.
Source code in bootstrap/bootstrap.py
get_return_type(bfunc)
infer_return_type(df, bfunc, **kwargs)
Infer the return type of a bootstrap function.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df
|
BFUNC_INPUT
|
The DataFrame to bootstrap. |
required |
bfunc
|
BFUNC
|
The bootstrap function. |
required |
**kwargs
|
kwargs
|
Keyword arguments to pass to the bootstrap function. |
{}
|
Returns:
Type | Description |
---|---|
Tuple[BFUNC, type]
|
A tuple of the bootstrap function and its return type. |
Raises:
Type | Description |
---|---|
UnsupportedReturnType
|
If the bootstrap function returns an unsupported type. |