Skip to content
New: Star-import, signal unraveling, Python 3.12 support, and more

#
accessors module

Custom Pandas accessors for generic data.

Methods can be accessed as follows:

- GenericSRAccessor -> `pd.Series.vbt.*`
- GenericDFAccessor -> `pd.DataFrame.vbt.*`

    >>> from vectorbtpro import *

    >>> # vectorbtpro.generic.accessors.GenericAccessor.rolling_mean
    >>> pd.Series([1, 2, 3, 4]).vbt.rolling_mean(2)
    0    NaN
    1    1.5
    2    2.5
    3    3.5
    dtype: float64

The accessors inherit vectorbtpro.base.accessors and are inherited by more specialized accessors, such as vectorbtpro.signals.accessors and vectorbtpro.returns.accessors.

Note

Grouping is only supported by the methods that accept the `group_by` argument.

Accessors do not utilize caching.

Run for the examples below

    >>> df = pd.DataFrame({
    ...     'a': [1, 2, 3, 4, 5],
    ...     'b': [5, 4, 3, 2, 1],
    ...     'c': [1, 2, 3, 2, 1]
    ... }, index=pd.Index(pd.date_range("2020", periods=5)))
    >>> df
                a  b  c
    2020-01-01  1  5  1
    2020-01-02  2  4  2
    2020-01-03  3  3  3
    2020-01-04  4  2  2
    2020-01-05  5  1  1

    >>> sr = pd.Series(np.arange(10), index=pd.date_range("2020", periods=10))
    >>> sr
    2020-01-01    0
    2020-01-02    1
    2020-01-03    2
    2020-01-04    3
    2020-01-05    4
    2020-01-06    5
    2020-01-07    6
    2020-01-08    7
    2020-01-09    8
    2020-01-10    9
    dtype: int64

## Stats

Hint

See StatsBuilderMixin.stats() and GenericAccessor.metrics.

    >>> df2 = pd.DataFrame({
    ...     'a': [np.nan, 2, 3],
    ...     'b': [4, np.nan, 5],
    ...     'c': [6, 7, np.nan]
    ... }, index=['x', 'y', 'z'])

    >>> df2.vbt(freq='d').stats(column='a')
    Start                      x
    End                        z
    Period       3 days 00:00:00
    Count                      2
    Mean                     2.5
    Std                 0.707107
    Min                      2.0
    Median                   2.5
    Max                      3.0
    Min Index                  y
    Max Index                  z
    Name: a, dtype: object

### Mapping

Mapping can be set both in GenericAccessor (preferred) and StatsBuilderMixin.stats():

    >>> mapping = {x: 'test_' + str(x) for x in pd.unique(df2.values.flatten())}
    >>> df2.vbt(freq='d', mapping=mapping).stats(column='a')
    Start                                   x
    End                                     z
    Period                    3 days 00:00:00
    Count                                   2
    Value Counts: test_2.0                  1
    Value Counts: test_3.0                  1
    Value Counts: test_4.0                  0
    Value Counts: test_5.0                  0
    Value Counts: test_6.0                  0
    Value Counts: test_7.0                  0
    Value Counts: test_nan                  1
    Name: a, dtype: object

    >>> df2.vbt(freq='d').stats(column='a', settings=dict(mapping=mapping))
    UserWarning: Changing the mapping will create a copy of this object.
    Consider setting it upon object creation to re-use existing cache.

    Start                                   x
    End                                     z
    Period                    3 days 00:00:00
    Count                                   2
    Value Counts: test_2.0                  1
    Value Counts: test_3.0                  1
    Value Counts: test_4.0                  0
    Value Counts: test_5.0                  0
    Value Counts: test_6.0                  0
    Value Counts: test_7.0                  0
    Value Counts: test_nan                  1
    Name: a, dtype: object

Selecting a column before calling `stats` will consider uniques from this column only:

    >>> df2['a'].vbt(freq='d', mapping=mapping).stats()
    Start                                   x
    End                                     z
    Period                    3 days 00:00:00
    Count                                   2
    Value Counts: test_2.0                  1
    Value Counts: test_3.0                  1
    Value Counts: test_nan                  1
    Name: a, dtype: object

To include all keys from `mapping`, pass `incl_all_keys=True`:

    >>> df2['a'].vbt(freq='d', mapping=mapping).stats(settings=dict(incl_all_keys=True))
    Start                                   x
    End                                     z
    Period                    3 days 00:00:00
    Count                                   2
    Value Counts: test_2.0                  1
    Value Counts: test_3.0                  1
    Value Counts: test_4.0                  0
    Value Counts: test_5.0                  0
    Value Counts: test_6.0                  0
    Value Counts: test_7.0                  0
    Value Counts: test_nan                  1
    Name: a, dtype: object

StatsBuilderMixin.stats() also supports (re-)grouping:

    >>> df2.vbt(freq='d').stats(column=0, group_by=[0, 0, 1])
    Start                      x
    End                        z
    Period       3 days 00:00:00
    Count                      4
    Mean                     3.5
    Std                 1.290994
    Min                      2.0
    Median                   3.5
    Max                      5.0
    Min Index                  y
    Max Index                  z
    Name: 0, dtype: object

## Plots

Hint

See PlotsBuilderMixin.plots() and GenericAccessor.subplots.

GenericAccessor class has a single subplot based on GenericAccessor.plot():

    >>> df2.vbt.plots().show()

## nb_config ReadonlyConfig

Config of Numba methods to be attached to GenericAccessor.

    ReadonlyConfig(
        shuffle=dict(
            func=CPUDispatcher(<function shuffle_nb at 0x7ff34a1c7640>),
            disable_chunked=True
        ),
        fillna=dict(
            func=CPUDispatcher(<function fillna_nb at 0x7ff34a2109d0>)
        ),
        bshift=dict(
            func=CPUDispatcher(<function bshift_nb at 0x7ff34a211000>)
        ),
        fshift=dict(
            func=CPUDispatcher(<function fshift_nb at 0x7ff34a211480>)
        ),
        diff=dict(
            func=CPUDispatcher(<function diff_nb at 0x7ff34a2117e0>)
        ),
        pct_change=dict(
            func=CPUDispatcher(<function pct_change_nb at 0x7ff34a211b40>)
        ),
        ffill=dict(
            func=CPUDispatcher(<function ffill_nb at 0x7ff34a212200>)
        ),
        bfill=dict(
            func=CPUDispatcher(<function bfill_nb at 0x7ff34a211ea0>)
        ),
        fbfill=dict(
            func=CPUDispatcher(<function fbfill_nb at 0x7ff34a210a60>)
        ),
        cumsum=dict(
            func=CPUDispatcher(<function nancumsum_nb at 0x7ff34a212680>)
        ),
        cumprod=dict(
            func=CPUDispatcher(<function nancumprod_nb at 0x7ff34a2128c0>)
        ),
        rolling_sum=dict(
            func=CPUDispatcher(<function rolling_sum_nb at 0x7ff35943a290>)
        ),
        rolling_prod=dict(
            func=CPUDispatcher(<function rolling_prod_nb at 0x7ff35943a7a0>)
        ),
        rolling_min=dict(
            func=CPUDispatcher(<function rolling_min_nb at 0x7ff35949f640>)
        ),
        rolling_max=dict(
            func=CPUDispatcher(<function rolling_max_nb at 0x7ff35949f9a0>)
        ),
        expanding_min=dict(
            func=CPUDispatcher(<function expanding_min_nb at 0x7ff359500e50>)
        ),
        expanding_max=dict(
            func=CPUDispatcher(<function expanding_max_nb at 0x7ff3595011b0>)
        ),
        rolling_any=dict(
            func=CPUDispatcher(<function rolling_any_nb at 0x7ff359500430>)
        ),
        rolling_all=dict(
            func=CPUDispatcher(<function rolling_all_nb at 0x7ff359500790>)
        ),
        product=dict(
            func=CPUDispatcher(<function nanprod_nb at 0x7ff34a212440>),
            is_reducing=True
        )
    )

## GenericAccessor class

    GenericAccessor(
        wrapper,
        obj=None,
        mapping=None,
        **kwargs
    )

Accessor on top of data of any type. For both, Series and DataFrames.

Accessible via `pd.Series.vbt` and `pd.DataFrame.vbt`.

Superclasses

- Analyzable
- AttrResolverMixin
- BaseAccessor
- Cacheable
- Chainable
- Comparable
- Configured
- ExtPandasIndexer
- HasSettings
- IndexingBase
- PandasIndexer
- Pickleable
- PlotsBuilderMixin
- Prettified
- StatsBuilderMixin
- Wrapping

Inherited members

- AttrResolverMixin.deep_getattr()
- AttrResolverMixin.post_resolve_attr()
- AttrResolverMixin.pre_resolve_attr()
- AttrResolverMixin.resolve_attr()
- AttrResolverMixin.resolve_shortcut_attr()
- BaseAccessor.align()
- BaseAccessor.align_to()
- BaseAccessor.apply()
- BaseAccessor.apply_and_concat()
- BaseAccessor.apply_on_index()
- BaseAccessor.broadcast()
- BaseAccessor.broadcast_combs()
- BaseAccessor.broadcast_to()
- BaseAccessor.cls_dir
- BaseAccessor.column_only_select
- BaseAccessor.column_stack()
- BaseAccessor.combine()
- BaseAccessor.concat()
- BaseAccessor.config
- BaseAccessor.cross()
- BaseAccessor.cross()
- BaseAccessor.cross_with()
- BaseAccessor.df_accessor_cls
- BaseAccessor.drop_duplicate_levels()
- BaseAccessor.drop_levels()
- BaseAccessor.drop_redundant_levels()
- BaseAccessor.empty()
- BaseAccessor.empty_like()
- BaseAccessor.eval()
- BaseAccessor.get()
- BaseAccessor.group_select
- BaseAccessor.iloc
- BaseAccessor.indexing_func()
- BaseAccessor.indexing_kwargs
- BaseAccessor.indexing_setter_func()
- BaseAccessor.loc
- BaseAccessor.make_symmetric()
- BaseAccessor.obj
- BaseAccessor.range_only_select
- BaseAccessor.rec_state
- BaseAccessor.rename_levels()
- BaseAccessor.repeat()
- BaseAccessor.resolve_column_stack_kwargs()
- BaseAccessor.resolve_row_stack_kwargs()
- BaseAccessor.resolve_shape()
- BaseAccessor.row_stack()
- BaseAccessor.select_levels()
- BaseAccessor.self_aliases
- BaseAccessor.set()
- BaseAccessor.set_between()
- BaseAccessor.sr_accessor_cls
- BaseAccessor.stack_index()
- BaseAccessor.tile()
- BaseAccessor.to_1d_array()
- BaseAccessor.to_2d_array()
- BaseAccessor.to_dict()
- BaseAccessor.unstack_to_array()
- BaseAccessor.unstack_to_df()
- BaseAccessor.wrapper
- BaseAccessor.xloc
- Cacheable.get_ca_setup()
- Chainable.pipe()
- Configured.copy()
- Configured.equals()
- Configured.get_writeable_attrs()
- Configured.prettify()
- Configured.replace()
- Configured.resolve_merge_kwargs()
- Configured.update_config()
- HasSettings.get_path_setting()
- HasSettings.get_path_settings()
- HasSettings.get_setting()
- HasSettings.get_settings()
- HasSettings.has_path_setting()
- HasSettings.has_path_settings()
- HasSettings.has_setting()
- HasSettings.has_settings()
- HasSettings.reset_settings()
- HasSettings.resolve_setting()
- HasSettings.resolve_settings_paths()
- HasSettings.set_settings()
- PandasIndexer.xs()
- Pickleable.decode_config()
- Pickleable.decode_config_node()
- Pickleable.dumps()
- Pickleable.encode_config()
- Pickleable.encode_config_node()
- Pickleable.file_exists()
- Pickleable.getsize()
- Pickleable.load()
- Pickleable.loads()
- Pickleable.modify_state()
- Pickleable.resolve_file_path()
- Pickleable.save()
- PlotsBuilderMixin.build_subplots_doc()
- PlotsBuilderMixin.override_subplots_doc()
- PlotsBuilderMixin.plots()
- StatsBuilderMixin.build_metrics_doc()
- StatsBuilderMixin.override_metrics_doc()
- StatsBuilderMixin.stats()
- Wrapping.regroup()
- Wrapping.resample()
- Wrapping.resolve_stack_kwargs()
- Wrapping.select_col()
- Wrapping.select_col_from_obj()
- Wrapping.split()

Subclasses

- GenericDFAccessor
- GenericSRAccessor
- ReturnsAccessor
- SignalsAccessor
- Vbt_Accessor

### ago method

    GenericAccessor.ago(
        n,
        fill_value=nan,
        get_indexer_kwargs=None,
        **kwargs
    )

For each value, get the value `n` periods ago.

### all_ago method

    GenericAccessor.all_ago(
        n,
        **kwargs
    )

For each value, check whether all values within a window of `n` last periods are True.

### any_ago method

    GenericAccessor.any_ago(
        n,
        **kwargs
    )

For each value, check whether any value within a window of `n` last periods is True.

### apply_along_axis class method

    GenericAccessor.apply_along_axis(
        apply_func_nb,
        *args,
        axis=1,
        broadcast_named_args=None,
        broadcast_kwargs=None,
        template_context=None,
        jitted=None,
        chunked=None,
        wrapper=None,
        wrap_kwargs=None
    )

See apply_nb() for `axis=1` and row_apply_nb() for `axis=0`.

For details on the meta version, see apply_meta_nb() for `axis=1` and row_apply_meta_nb() for `axis=0`.

Usage

- Using regular function:

    >>> power_nb = njit(lambda a: np.power(a, 2))

    >>> df.vbt.apply_along_axis(power_nb)
                 a   b  c
    2020-01-01   1  25  1
    2020-01-02   4  16  4
    2020-01-03   9   9  9
    2020-01-04  16   4  4
    2020-01-05  25   1  1

- Using meta function:

    >>> ratio_meta_nb = njit(lambda col, a, b: a[:, col] / b[:, col])

    >>> vbt.pd_acc.apply_along_axis(
    ...     ratio_meta_nb,
    ...     df.vbt.to_2d_array() - 1,
    ...     df.vbt.to_2d_array() + 1,
    ...     wrapper=df.vbt.wrapper
    ... )
                       a         b         c
    2020-01-01  0.000000  0.666667  0.000000
    2020-01-02  0.333333  0.600000  0.333333
    2020-01-03  0.500000  0.500000  0.500000
    2020-01-04  0.600000  0.333333  0.333333
    2020-01-05  0.666667  0.000000  0.000000

- Using templates and broadcasting:

    >>> vbt.pd_acc.apply_along_axis(
    ...     ratio_meta_nb,
    ...     vbt.Rep('a'),
    ...     vbt.Rep('b'),
    ...     broadcast_named_args=dict(
    ...         a=pd.Series([1, 2, 3, 4, 5], index=df.index),
    ...         b=pd.DataFrame([[1, 2, 3]], columns=['a', 'b', 'c'])
    ...     )
    ... )
                  a    b         c
    2020-01-01  1.0  0.5  0.333333
    2020-01-02  2.0  1.0  0.666667
    2020-01-03  3.0  1.5  1.000000
    2020-01-04  4.0  2.0  1.333333
    2020-01-05  5.0  2.5  1.666667

### apply_and_reduce class method

    GenericAccessor.apply_and_reduce(
        apply_func_nb,
        reduce_func_nb,
        apply_args=None,
        reduce_args=None,
        broadcast_named_args=None,
        broadcast_kwargs=None,
        template_context=None,
        jitted=None,
        chunked=None,
        wrapper=None,
        wrap_kwargs=None
    )

See apply_and_reduce_nb().

For details on the meta version, see apply_and_reduce_meta_nb().

Usage

- Using regular function:

    >>> greater_nb = njit(lambda a: a[a > 2])
    >>> mean_nb = njit(lambda a: np.nanmean(a))

    >>> df.vbt.apply_and_reduce(greater_nb, mean_nb)
    a    4.0
    b    4.0
    c    3.0
    Name: apply_and_reduce, dtype: float64

- Using meta function:

    >>> and_meta_nb = njit(lambda col, a, b: a[:, col] & b[:, col])
    >>> sum_meta_nb = njit(lambda col, x: np.sum(x))

    >>> vbt.pd_acc.apply_and_reduce(
    ...     and_meta_nb,
    ...     sum_meta_nb,
    ...     apply_args=(
    ...         df.vbt.to_2d_array() > 1,
    ...         df.vbt.to_2d_array() < 4
    ...     ),
    ...     wrapper=df.vbt.wrapper
    ... )
    a    2
    b    2
    c    3
    Name: apply_and_reduce, dtype: int64

- Using templates and broadcasting:

    >>> vbt.pd_acc.apply_and_reduce(
    ...     and_meta_nb,
    ...     sum_meta_nb,
    ...     apply_args=(
    ...         vbt.Rep('mask_a'),
    ...         vbt.Rep('mask_b')
    ...     ),
    ...     broadcast_named_args=dict(
    ...         mask_a=pd.Series([True, True, True, False, False], index=df.index),
    ...         mask_b=pd.DataFrame([[True, True, False]], columns=['a', 'b', 'c'])
    ...     )
    ... )
    a    3
    b    3
    c    0
    Name: apply_and_reduce, dtype: int64

### apply_mapping method

    GenericAccessor.apply_mapping(
        mapping=None,
        **kwargs
    )

See apply_mapping().

### areaplot method

    GenericAccessor.areaplot(
        line_shape='spline',
        trace_kwargs=None,
        add_trace_kwargs=None,
        fig=None,
        **layout_kwargs
    )

Plot stacked area.

Args

`line_shape` :`str`
  Line shape.
`trace_kwargs` :`dict`
  Keyword arguments passed to `plotly.graph_objects.Scatter`.
`add_trace_kwargs` :`dict`
  Keyword arguments passed to `add_trace`.
`fig` :`Figure` or `FigureWidget`
  Figure to add traces to.
`**layout_kwargs`
  Keyword arguments for layout.

Usage

    >>> df.vbt.areaplot().show()

### barplot method

    GenericAccessor.barplot(
        column=None,
        trace_names=None,
        x_labels=None,
        return_fig=True,
        **kwargs
    )

Create Bar and return the figure.

Usage

    >>> df.vbt.barplot().show()

### bfill method

    GenericAccessor.bfill(
        *,
        jitted=None,
        chunked=None,
        wrap_kwargs=None
    )

See bfill_nb().

### binarize method

    GenericAccessor.binarize(
        *,
        threshold=0.0,
        copy=True,
        **kwargs
    )

See `sklearn.preprocessing.Binarizer`.

### boxplot method

    GenericAccessor.boxplot(
        column=None,
        by_level=None,
        trace_names=None,
        group_by=None,
        return_fig=True,
        **kwargs
    )

Create Box and return the figure.

Usage

    >>> df.vbt.boxplot().show()

### bshift method

    GenericAccessor.bshift(
        n=1,
        fill_value=nan,
        *,
        jitted=None,
        chunked=None,
        wrap_kwargs=None
    )

See bshift_nb().

### column_apply class method

    GenericAccessor.column_apply(
        *args,
        **kwargs
    )

GenericAccessor.apply_along_axis() with `axis=1`.

### corr method

    GenericAccessor.corr(
        other,
        broadcast_kwargs=None,
        jitted=None,
        chunked=None,
        group_by=None,
        wrap_kwargs=None
    )

Return correlation coefficient of non-NaN elements.

### count method

    GenericAccessor.count(
        use_jitted=None,
        jitted=None,
        chunked=None,
        group_by=None,
        wrap_kwargs=None
    )

Return count of non-NaN elements.

### cov method

    GenericAccessor.cov(
        other,
        ddof=1,
        broadcast_kwargs=None,
        jitted=None,
        chunked=None,
        group_by=None,
        wrap_kwargs=None
    )

Return covariance of non-NaN elements.

### crossed_above method

    GenericAccessor.crossed_above(
        other,
        wait=0,
        dropna=False,
        broadcast_kwargs=None,
        jitted=None,
        chunked=None,
        wrap_kwargs=None
    )

See crossed_above_nb().

Usage

    >>> df['b'].vbt.crossed_above(df['c'])
    2020-01-01    False
    2020-01-02    False
    2020-01-03    False
    2020-01-04    False
    2020-01-05    False
    dtype: bool

    >>> df['a'].vbt.crossed_above(df['b'])
    2020-01-01    False
    2020-01-02    False
    2020-01-03    False
    2020-01-04     True
    2020-01-05    False
    dtype: bool

    >>> df['a'].vbt.crossed_above(df['b'], wait=1)
    2020-01-01    False
    2020-01-02    False
    2020-01-03    False
    2020-01-04    False
    2020-01-05     True
    dtype: bool

### crossed_below method

    GenericAccessor.crossed_below(
        other,
        wait=0,
        dropna=True,
        broadcast_kwargs=None,
        jitted=None,
        chunked=None,
        wrap_kwargs=None
    )

See crossed_below_nb().

Also, see GenericAccessor.crossed_above() for similar examples.

### cumprod method

    GenericAccessor.cumprod(
        *,
        jitted=None,
        chunked=None,
        wrap_kwargs=None
    )

See nancumprod_nb().

### cumsum method

    GenericAccessor.cumsum(
        *,
        jitted=None,
        chunked=None,
        wrap_kwargs=None
    )

See nancumsum_nb().

### demean method

    GenericAccessor.demean(
        jitted=None,
        chunked=None,
        group_by=None,
        wrap_kwargs=None
    )

See demean_nb().

### describe method

    GenericAccessor.describe(
        percentiles=None,
        ddof=1,
        jitted=None,
        chunked=None,
        group_by=None,
        wrap_kwargs=None
    )

See describe_reduce_nb().

For `percentiles`, see `pd.DataFrame.describe`.

Usage

    >>> df.vbt.describe()
                  a         b        c
    count  5.000000  5.000000  5.00000
    mean   3.000000  3.000000  1.80000
    std    1.581139  1.581139  0.83666
    min    1.000000  1.000000  1.00000
    25%    2.000000  2.000000  1.00000
    50%    3.000000  3.000000  2.00000
    75%    4.000000  4.000000  2.00000
    max    5.000000  5.000000  3.00000

### diff method

    GenericAccessor.diff(
        n=1,
        *,
        jitted=None,
        chunked=None,
        wrap_kwargs=None
    )

See diff_nb().

### digitize method

    GenericAccessor.digitize(
        bins='auto',
        right=False,
        return_mapping=False,
        wrap_kwargs=None
    )

Apply `np.digitize`.

Usage

    >>> df.vbt.digitize(3)
                a  b  c
    2020-01-01  1  3  1
    2020-01-02  1  3  1
    2020-01-03  2  2  2
    2020-01-04  3  1  1
    2020-01-05  3  1  1

### drawdown method

    GenericAccessor.drawdown(
        jitted=None,
        chunked=None,
        wrap_kwargs=None
    )

Get drawdown series.

### drawdowns property

GenericAccessor.get_drawdowns() with default arguments.

### ewm_mean method

    GenericAccessor.ewm_mean(
        span,
        minp=0,
        adjust=True,
        jitted=None,
        chunked=None,
        wrap_kwargs=None
    )

See ewm_mean_nb().

### ewm_std method

    GenericAccessor.ewm_std(
        span,
        minp=0,
        adjust=True,
        jitted=None,
        chunked=None,
        wrap_kwargs=None
    )

See ewm_std_nb().

### expanding_apply class method

    GenericAccessor.expanding_apply(
        *args,
        **kwargs
    )

GenericAccessor.rolling_apply() but expanding.

### expanding_corr method

    GenericAccessor.expanding_corr(
        other,
        minp=1,
        **kwargs
    )

Expanding version of GenericAccessor.rolling_corr().

### expanding_cov method

    GenericAccessor.expanding_cov(
        other,
        minp=1,
        **kwargs
    )

Expanding version of GenericAccessor.rolling_cov().

### expanding_idxmax method

    GenericAccessor.expanding_idxmax(
        minp=1,
        **kwargs
    )

Expanding version of GenericAccessor.rolling_idxmax().

### expanding_idxmin method

    GenericAccessor.expanding_idxmin(
        minp=1,
        **kwargs
    )

Expanding version of GenericAccessor.rolling_idxmin().

### expanding_max method

    GenericAccessor.expanding_max(
        minp=1,
        *,
        jitted=None,
        chunked=None,
        wrap_kwargs=None
    )

See expanding_max_nb().

### expanding_mean method

    GenericAccessor.expanding_mean(
        minp=1,
        **kwargs
    )

Expanding version of GenericAccessor.rolling_mean().

### expanding_min method

    GenericAccessor.expanding_min(
        minp=1,
        *,
        jitted=None,
        chunked=None,
        wrap_kwargs=None
    )

See expanding_min_nb().

### expanding_ols method

    GenericAccessor.expanding_ols(
        other,
        minp=1,
        **kwargs
    )

Expanding version of GenericAccessor.rolling_ols().

### expanding_rank method

    GenericAccessor.expanding_rank(
        minp=1,
        **kwargs
    )

Expanding version of GenericAccessor.rolling_rank().

### expanding_std method

    GenericAccessor.expanding_std(
        minp=1,
        **kwargs
    )

Expanding version of GenericAccessor.rolling_std().

### expanding_zscore method

    GenericAccessor.expanding_zscore(
        minp=1,
        **kwargs
    )

Expanding version of GenericAccessor.rolling_zscore().

### fbfill method

    GenericAccessor.fbfill(
        *,
        jitted=None,
        chunked=None,
        wrap_kwargs=None
    )

See fbfill_nb().

### ffill method

    GenericAccessor.ffill(
        *,
        jitted=None,
        chunked=None,
        wrap_kwargs=None
    )

See ffill_nb().

### fillna method

    GenericAccessor.fillna(
        value,
        *,
        jitted=None,
        chunked=None,
        wrap_kwargs=None
    )

See fillna_nb().

### find_pattern method

    GenericAccessor.find_pattern(
        *args,
        **kwargs
    )

Generate pattern range records.

See PatternRanges.from_pattern_search().

### flatten_grouped method

    GenericAccessor.flatten_grouped(
        order='C',
        jitted=None,
        group_by=None,
        wrap_kwargs=None
    )

Flatten each group of columns.

See flatten_grouped_nb(). If all groups have the same length, see flatten_uniform_grouped_nb().

Warning

Make sure that the distribution of group lengths is close to uniform, otherwise groups with less columns will be filled with NaN and needlessly occupy memory.

Usage

    >>> group_by = pd.Series(['first', 'first', 'second'], name='group')
    >>> df.vbt.flatten_grouped(group_by=group_by, order='C')
    group       first  second
    2020-01-01    1.0     1.0
    2020-01-01    5.0     NaN
    2020-01-02    2.0     2.0
    2020-01-02    4.0     NaN
    2020-01-03    3.0     3.0
    2020-01-03    3.0     NaN
    2020-01-04    4.0     2.0
    2020-01-04    2.0     NaN
    2020-01-05    5.0     1.0
    2020-01-05    1.0     NaN

    >>> df.vbt.flatten_grouped(group_by=group_by, order='F')
    group       first  second
    2020-01-01    1.0     1.0
    2020-01-02    2.0     2.0
    2020-01-03    3.0     3.0
    2020-01-04    4.0     2.0
    2020-01-05    5.0     1.0
    2020-01-01    5.0     NaN
    2020-01-02    4.0     NaN
    2020-01-03    3.0     NaN
    2020-01-04    2.0     NaN
    2020-01-05    1.0     NaN

### fshift method

    GenericAccessor.fshift(
        n=1,
        fill_value=nan,
        *,
        jitted=None,
        chunked=None,
        wrap_kwargs=None
    )

See fshift_nb().

### get_drawdowns method

    GenericAccessor.get_drawdowns(
        *args,
        wrapper_kwargs=None,
        **kwargs
    )

Generate drawdown records.

See Drawdowns.from_price().

### get_ranges method

    GenericAccessor.get_ranges(
        *args,
        wrapper_kwargs=None,
        **kwargs
    )

Generate range records.

See Ranges.from_array().

### groupby_apply class method

    GenericAccessor.groupby_apply(
        by,
        reduce_func_nb,
        *args,
        groupby_kwargs=None,
        broadcast_named_args=None,
        broadcast_kwargs=None,
        template_context=None,
        jitted=None,
        chunked=None,
        wrapper=None,
        wrap_kwargs=None
    )

See groupby_reduce_nb().

For details on the meta version, see groupby_reduce_meta_nb().

Argument `by` can be an instance of Grouper, `pandas.core.groupby.GroupBy`, `pandas.core.resample.Resampler`, or any other groupby-like object that can be accepted by Grouper, or if it fails, then by `pd.DataFrame.groupby` with `groupby_kwargs` passed as keyword arguments.

Usage

- Using regular function:

    >>> mean_nb = njit(lambda a: np.nanmean(a))

    >>> df.vbt.groupby_apply([1, 1, 2, 2, 3], mean_nb)
         a    b    c
    1  1.5  4.5  1.5
    2  3.5  2.5  2.5
    3  5.0  1.0  1.0

- Using meta function:

    >>> mean_ratio_meta_nb = njit(lambda idxs, group, col, a, b: \
    ...     np.mean(a[idxs, col]) / np.mean(b[idxs, col]))

    >>> vbt.pd_acc.groupby_apply(
    ...     [1, 1, 2, 2, 3],
    ...     mean_ratio_meta_nb,
    ...     df.vbt.to_2d_array() - 1,
    ...     df.vbt.to_2d_array() + 1,
    ...     wrapper=df.vbt.wrapper
    ... )
              a         b         c
    1  0.200000  0.636364  0.200000
    2  0.555556  0.428571  0.428571
    3  0.666667  0.000000  0.000000

- Using templates and broadcasting, let's split both input arrays into 2 groups of rows and run the calculation function on each group:

    >>> from vectorbtpro.base.grouping.nb import group_by_evenly_nb

    >>> vbt.pd_acc.groupby_apply(
    ...     vbt.RepEval('group_by_evenly_nb(wrapper.shape[0], 2)'),
    ...     mean_ratio_meta_nb,
    ...     vbt.Rep('a'),
    ...     vbt.Rep('b'),
    ...     broadcast_named_args=dict(
    ...         a=pd.Series([1, 2, 3, 4, 5], index=df.index),
    ...         b=pd.DataFrame([[1, 2, 3]], columns=['a', 'b', 'c'])
    ...     ),
    ...     template_context=dict(group_by_evenly_nb=group_by_evenly_nb)
    ... )
         a     b         c
    0  2.0  1.00  0.666667
    1  4.5  2.25  1.500000

The advantage of the approach above is in the flexibility: we can pass two arrays of any broadcastable shapes and everything else is done for us.

### groupby_transform class method

    GenericAccessor.groupby_transform(
        by,
        transform_func_nb,
        *args,
        groupby_kwargs=None,
        broadcast_named_args=None,
        broadcast_kwargs=None,
        template_context=None,
        jitted=None,
        wrapper=None,
        wrap_kwargs=None
    )

See groupby_transform_nb().

For details on the meta version, see groupby_transform_meta_nb().

For argument `by`, see GenericAccessor.groupby_apply().

Usage

- Using regular function:

    >>> zscore_nb = njit(lambda a: (a - np.nanmean(a)) / np.nanstd(a))

    >>> df.vbt.groupby_transform([1, 1, 2, 2, 3], zscore_nb)
                       a         b         c
    2020-01-01 -1.000000  1.666667 -1.000000
    2020-01-02 -0.333333  1.000000 -0.333333
    2020-01-03  0.242536  0.242536  0.242536
    2020-01-04  1.697749 -1.212678 -1.212678
    2020-01-05  1.414214 -0.707107 -0.707107

- Using meta function:

    >>> zscore_ratio_meta_nb = njit(lambda idxs, group, a, b: \
    ...     zscore_nb(a[idxs]) / zscore_nb(b[idxs]))

    >>> vbt.pd_acc.groupby_transform(
    ...     [1, 1, 2, 2, 3],
    ...     zscore_ratio_meta_nb,
    ...     df.vbt.to_2d_array(),
    ...     df.vbt.to_2d_array()[::-1],
    ...     wrapper=df.vbt.wrapper
    ... )
                       a         b    c
    2020-01-01 -0.600000 -1.666667  1.0
    2020-01-02 -0.333333 -3.000000  1.0
    2020-01-03  1.000000  1.000000  1.0
    2020-01-04 -1.400000 -0.714286  1.0
    2020-01-05 -2.000000 -0.500000  1.0

### heatmap method

    GenericAccessor.heatmap(
        column=None,
        x_level=None,
        y_level=None,
        symmetric=False,
        sort=True,
        x_labels=None,
        y_labels=None,
        slider_level=None,
        active=0,
        slider_labels=None,
        return_fig=True,
        fig=None,
        **kwargs
    )

Create a heatmap figure based on object's multi-index and values.

If the object is two-dimensional or the index is not a multi-index, returns a regular heatmap.

If multi-index contains more than two levels or you want them in specific order, pass `x_level` and `y_level`, each (`int` if index or `str` if name) corresponding to an axis of the heatmap. Optionally, pass `slider_level` to use a level as a slider.

Creates Heatmap and returns the figure.

Usage

- Plotting a figure based on a regular index:

    >>> df = pd.DataFrame([
    ...     [0, np.nan, np.nan],
    ...     [np.nan, 1, np.nan],
    ...     [np.nan, np.nan, 2]
    ... ])
    >>> df.vbt.heatmap().show()

- Plotting a figure based on a multi-index:

    >>> multi_index = pd.MultiIndex.from_tuples([
    ...     (1, 1),
    ...     (2, 2),
    ...     (3, 3)
    ... ])
    >>> sr = pd.Series(np.arange(len(multi_index)), index=multi_index)
    >>> sr
    1  1    0
    2  2    1
    3  3    2
    dtype: int64

    >>> sr.vbt.heatmap().show()

### histplot method

    GenericAccessor.histplot(
        column=None,
        by_level=None,
        trace_names=None,
        group_by=None,
        return_fig=True,
        **kwargs
    )

Create Histogram and return the figure.

Usage

    >>> df.vbt.histplot().show()

### idxmax method

    GenericAccessor.idxmax(
        order='C',
        jitted=None,
        chunked=None,
        group_by=None,
        wrap_kwargs=None
    )

Return labeled index of max of non-NaN elements.

### idxmin method

    GenericAccessor.idxmin(
        order='C',
        jitted=None,
        chunked=None,
        group_by=None,
        wrap_kwargs=None
    )

Return labeled index of min of non-NaN elements.

### lineplot method

    GenericAccessor.lineplot(
        column=None,
        **kwargs
    )

GenericAccessor.plot() with 'lines' mode.

Usage

    >>> df.vbt.lineplot().show()

### ma method

    GenericAccessor.ma(
        window,
        wtype='simple',
        minp=0,
        adjust=True,
        jitted=None,
        chunked=None,
        wrap_kwargs=None
    )

See ma_nb().

### map class method

    GenericAccessor.map(
        map_func_nb,
        *args,
        broadcast_named_args=None,
        broadcast_kwargs=None,
        template_context=None,
        jitted=None,
        chunked=None,
        wrapper=None,
        wrap_kwargs=None
    )

See map_nb().

For details on the meta version, see map_meta_nb().

Usage

- Using regular function:

    >>> prod_nb = njit(lambda a, x: a * x)

    >>> df.vbt.map(prod_nb, 10)
                 a   b   c
    2020-01-01  10  50  10
    2020-01-02  20  40  20
    2020-01-03  30  30  30
    2020-01-04  40  20  20
    2020-01-05  50  10  10

- Using meta function:

    >>> diff_meta_nb = njit(lambda i, col, a, b: a[i, col] / b[i, col])

    >>> vbt.pd_acc.map(
    ...     diff_meta_nb,
    ...     df.vbt.to_2d_array() - 1,
    ...     df.vbt.to_2d_array() + 1,
    ...     wrapper=df.vbt.wrapper
    ... )
                       a         b         c
    2020-01-01  0.000000  0.666667  0.000000
    2020-01-02  0.333333  0.600000  0.333333
    2020-01-03  0.500000  0.500000  0.500000
    2020-01-04  0.600000  0.333333  0.333333
    2020-01-05  0.666667  0.000000  0.000000

- Using templates and broadcasting:

    >>> vbt.pd_acc.map(
    ...     diff_meta_nb,
    ...     vbt.Rep('a'),
    ...     vbt.Rep('b'),
    ...     broadcast_named_args=dict(
    ...         a=pd.Series([1, 2, 3, 4, 5], index=df.index),
    ...         b=pd.DataFrame([[1, 2, 3]], columns=['a', 'b', 'c'])
    ...     )
    ... )
                  a    b         c
    2020-01-01  1.0  0.5  0.333333
    2020-01-02  2.0  1.0  0.666667
    2020-01-03  3.0  1.5  1.000000
    2020-01-04  4.0  2.0  1.333333
    2020-01-05  5.0  2.5  1.666667

### mapping property

Mapping.

### max method

    GenericAccessor.max(
        use_jitted=None,
        jitted=None,
        chunked=None,
        group_by=None,
        wrap_kwargs=None
    )

Return max of non-NaN elements.

### maxabs_scale method

    GenericAccessor.maxabs_scale(
        *,
        copy=True,
        **kwargs
    )

See `sklearn.preprocessing.MaxAbsScaler`.

### mean method

    GenericAccessor.mean(
        use_jitted=None,
        jitted=None,
        chunked=None,
        group_by=None,
        wrap_kwargs=None
    )

Return mean of non-NaN elements.

### median method

    GenericAccessor.median(
        use_jitted=None,
        jitted=None,
        chunked=None,
        group_by=None,
        wrap_kwargs=None
    )

Return median of non-NaN elements.

### metrics class variable

Metrics supported by GenericAccessor.

    HybridConfig(
        start=dict(
            title='Start',
            calc_func=<function GenericAccessor.<lambda> at 0x7ff34a366e60>,
            agg_func=None,
            tags='wrapper'
        ),
        end=dict(
            title='End',
            calc_func=<function GenericAccessor.<lambda> at 0x7ff34a366ef0>,
            agg_func=None,
            tags='wrapper'
        ),
        period=dict(
            title='Period',
            calc_func=<function GenericAccessor.<lambda> at 0x7ff34a366f80>,
            apply_to_timedelta=True,
            agg_func=None,
            tags='wrapper'
        ),
        count=dict(
            title='Count',
            calc_func='count',
            inv_check_has_mapping=True,
            tags=[
                'generic',
                'describe'
            ]
        ),
        mean=dict(
            title='Mean',
            calc_func='mean',
            inv_check_has_mapping=True,
            tags=[
                'generic',
                'describe'
            ]
        ),
        std=dict(
            title='Std',
            calc_func='std',
            inv_check_has_mapping=True,
            tags=[
                'generic',
                'describe'
            ]
        ),
        min=dict(
            title='Min',
            calc_func='min',
            inv_check_has_mapping=True,
            tags=[
                'generic',
                'describe'
            ]
        ),
        median=dict(
            title='Median',
            calc_func='median',
            inv_check_has_mapping=True,
            tags=[
                'generic',
                'describe'
            ]
        ),
        max=dict(
            title='Max',
            calc_func='max',
            inv_check_has_mapping=True,
            tags=[
                'generic',
                'describe'
            ]
        ),
        idx_min=dict(
            title='Min Index',
            calc_func='idxmin',
            agg_func=None,
            inv_check_has_mapping=True,
            tags=[
                'generic',
                'index'
            ]
        ),
        idx_max=dict(
            title='Max Index',
            calc_func='idxmax',
            agg_func=None,
            inv_check_has_mapping=True,
            tags=[
                'generic',
                'index'
            ]
        ),
        value_counts=dict(
            title='Value Counts',
            calc_func=<function GenericAccessor.<lambda> at 0x7ff34a367010>,
            resolve_value_counts=True,
            check_has_mapping=True,
            tags=[
                'generic',
                'value_counts'
            ]
        )
    )

Returns `GenericAccessor._metrics`, which gets (hybrid-) copied upon creation of each instance. Thus, changing this config won't affect the class.

To change metrics, you can either change the config in-place, override this property, or overwrite the instance variable `GenericAccessor._metrics`.

### min method

    GenericAccessor.min(
        use_jitted=None,
        jitted=None,
        chunked=None,
        group_by=None,
        wrap_kwargs=None
    )

Return min of non-NaN elements.

### minmax_scale method

    GenericAccessor.minmax_scale(
        feature_range=(0, 1),
        *,
        copy=True,
        clip=False,
        **kwargs
    )

See `sklearn.preprocessing.MinMaxScaler`.

### msd method

    GenericAccessor.msd(
        window,
        wtype='simple',
        minp=0,
        adjust=True,
        ddof=1,
        jitted=None,
        chunked=None,
        wrap_kwargs=None
    )

See msd_nb().

### normalize method

    GenericAccessor.normalize(
        norm='l2',
        *,
        copy=True,
        **kwargs
    )

See `sklearn.preprocessing.Normalizer`.

### overlay_with_heatmap method

    GenericAccessor.overlay_with_heatmap(
        other,
        column=None,
        trace_kwargs=None,
        heatmap_kwargs=None,
        add_trace_kwargs=None,
        fig=None,
        **layout_kwargs
    )

Plot Series as a line and overlays it with a heatmap.

Args

`other` :`array_like`
  Second array. Will broadcast.
`column` :`hashable`
  Column to plot.
`trace_kwargs` :`dict`
  Keyword arguments passed to `plotly.graph_objects.Scatter`.
`heatmap_kwargs` :`dict`
  Keyword arguments passed to GenericAccessor.heatmap().
`add_trace_kwargs` :`dict`
  Keyword arguments passed to `add_trace`.
`fig` :`Figure` or `FigureWidget`
  Figure to add traces to.
`**layout_kwargs`
  Keyword arguments for layout.

Usage

    >>> df['a'].vbt.overlay_with_heatmap(df['b']).show()

### pct_change method

    GenericAccessor.pct_change(
        n=1,
        *,
        jitted=None,
        chunked=None,
        wrap_kwargs=None
    )

See pct_change_nb().

### plot method

    GenericAccessor.plot(
        column=None,
        trace_names=None,
        x_labels=None,
        return_fig=True,
        **kwargs
    )

Create Scatter and return the figure.

Usage

    >>> df.vbt.plot().show()

### plot_against method

    GenericAccessor.plot_against(
        other,
        column=None,
        trace_kwargs=None,
        other_trace_kwargs=None,
        pos_trace_kwargs=None,
        neg_trace_kwargs=None,
        hidden_trace_kwargs=None,
        add_trace_kwargs=None,
        fig=None,
        **layout_kwargs
    )

Plot Series as a line against another line.

Args

`other` :`array_like`
  Second array. Will broadcast.
`column` :`hashable`
  Column to plot.
`trace_kwargs` :`dict`
  Keyword arguments passed to `plotly.graph_objects.Scatter`.
`other_trace_kwargs` :`dict`

  Keyword arguments passed to `plotly.graph_objects.Scatter` for `other`.

  Set to 'hidden' to hide.

`pos_trace_kwargs` :`dict`
  Keyword arguments passed to `plotly.graph_objects.Scatter` for positive line.
`neg_trace_kwargs` :`dict`
  Keyword arguments passed to `plotly.graph_objects.Scatter` for negative line.
`hidden_trace_kwargs` :`dict`
  Keyword arguments passed to `plotly.graph_objects.Scatter` for hidden lines.
`add_trace_kwargs` :`dict`
  Keyword arguments passed to `add_trace`.
`fig` :`Figure` or `FigureWidget`
  Figure to add traces to.
`**layout_kwargs`
  Keyword arguments for layout.

Usage

    >>> df['a'].vbt.plot_against(df['b']).show()

### plot_pattern method

    GenericAccessor.plot_pattern(
        pattern,
        interp_mode='mixed',
        rescale_mode='minmax',
        vmin=nan,
        vmax=nan,
        pmin=nan,
        pmax=nan,
        invert=False,
        error_type='absolute',
        max_error=nan,
        max_error_interp_mode=None,
        column=None,
        plot_obj=True,
        fill_distance=False,
        obj_trace_kwargs=None,
        pattern_trace_kwargs=None,
        lower_max_error_trace_kwargs=None,
        upper_max_error_trace_kwargs=None,
        add_trace_kwargs=None,
        fig=None,
        **layout_kwargs
    )

Plot pattern.

Mimics the same similarity calculation procedure as implemented in pattern_similarity_nb().

Usage

    >>> sr = pd.Series([10, 11, 12, 13, 12, 13, 14, 15, 13, 14, 11])
    >>> sr.vbt.plot_pattern([1, 2, 3, 2, 1]).show()

### plots_defaults property

Defaults for PlotsBuilderMixin.plots().

Merges PlotsBuilderMixin.plots_defaults and `plots` from generic.

### power_transform method

    GenericAccessor.power_transform(
        method='yeo-johnson',
        *,
        standardize=True,
        copy=True,
        **kwargs
    )

See `sklearn.preprocessing.PowerTransformer`.

### product method

    GenericAccessor.product(
        *,
        jitted=None,
        chunked=None,
        wrap_kwargs=None
    )

See nanprod_nb().

### proximity_apply class method

    GenericAccessor.proximity_apply(
        window,
        reduce_func_nb,
        *args,
        broadcast_named_args=None,
        broadcast_kwargs=None,
        template_context=None,
        jitted=None,
        wrapper=None,
        wrap_kwargs=None
    )

See proximity_reduce_nb().

For details on the meta version, see proximity_reduce_meta_nb().

Usage

- Using regular function:

    >>> mean_nb = njit(lambda a: np.nanmean(a))

    >>> df.vbt.proximity_apply(1, mean_nb)
                  a         b         c
    2020-01-01  3.0  2.500000  3.000000
    2020-01-02  3.0  2.666667  3.000000
    2020-01-03  3.0  2.777778  2.666667
    2020-01-04  3.0  2.666667  2.000000
    2020-01-05  3.0  2.500000  1.500000

- Using meta function:

    >>> @njit
    ... def mean_ratio_meta_nb(from_i, to_i, from_col, to_col, a, b):
    ...     a_mean = np.mean(a[from_i:to_i, from_col:to_col])
    ...     b_mean = np.mean(b[from_i:to_i, from_col:to_col])
    ...     return a_mean / b_mean

    >>> vbt.pd_acc.proximity_apply(
    ...     1,
    ...     mean_ratio_meta_nb,
    ...     df.vbt.to_2d_array() - 1,
    ...     df.vbt.to_2d_array() + 1,
    ...     wrapper=df.vbt.wrapper,
    ... )
                  a         b         c
    2020-01-01  0.5  0.428571  0.500000
    2020-01-02  0.5  0.454545  0.500000
    2020-01-03  0.5  0.470588  0.454545
    2020-01-04  0.5  0.454545  0.333333
    2020-01-05  0.5  0.428571  0.200000

- Using templates and broadcasting:

    >>> vbt.pd_acc.proximity_apply(
    ...     1,
    ...     mean_ratio_meta_nb,
    ...     vbt.Rep('a'),
    ...     vbt.Rep('b'),
    ...     broadcast_named_args=dict(
    ...         a=pd.Series([1, 2, 3, 4, 5], index=df.index),
    ...         b=pd.DataFrame([[1, 2, 3]], columns=['a', 'b', 'c'])
    ...     )
    ... )
                       a     b    c
    2020-01-01  1.000000  0.75  0.6
    2020-01-02  1.333333  1.00  0.8
    2020-01-03  2.000000  1.50  1.2
    2020-01-04  2.666667  2.00  1.6
    2020-01-05  3.000000  2.25  1.8

### qqplot method

    GenericAccessor.qqplot(
        column=None,
        sparams=(),
        dist='norm',
        plot_line=True,
        line_shape_kwargs=None,
        xref='x',
        yref='y',
        fig=None,
        **kwargs
    )

Plot probability plot using `scipy.stats.probplot`.

`**kwargs` are passed to GenericAccessor.scatterplot().

Usage

    >>> pd.Series(np.random.standard_normal(100)).vbt.qqplot().show()

### quantile_transform method

    GenericAccessor.quantile_transform(
        *,
        n_quantiles=1000,
        output_distribution='uniform',
        ignore_implicit_zeros=False,
        subsample=100000,
        random_state=None,
        copy=True,
        **kwargs
    )

See `sklearn.preprocessing.QuantileTransformer`.

### ranges property

GenericAccessor.get_ranges() with default arguments.

### rank method

    GenericAccessor.rank(
        pct=False,
        jitted=None,
        chunked=None,
        wrap_kwargs=None
    )

Compute numerical data rank.

By default, equal values are assigned a rank that is the average of the ranks of those values.

### realign method

    GenericAccessor.realign(
        index,
        freq=None,
        nan_value=None,
        ffill=True,
        source_rbound=False,
        target_rbound=False,
        jitted=None,
        chunked=None,
        wrap_kwargs=None,
        silence_warnings=None
    )

See realign_nb().

`index` can be either an instance of Resampler, or any index-like object.

Gives the same results as `df.resample(closed='right', label='right').last().ffill()` when applied on the target index of the resampler.

Usage

- Downsampling:

    >>> h_index = pd.date_range('2020-01-01', '2020-01-05', freq='1h')
    >>> d_index = pd.date_range('2020-01-01', '2020-01-05', freq='1d')

    >>> h_sr = pd.Series(range(len(h_index)), index=h_index)
    >>> h_sr.vbt.realign(d_index)
    2020-01-01     0.0
    2020-01-02    24.0
    2020-01-03    48.0
    2020-01-04    72.0
    2020-01-05    96.0
    Freq: D, dtype: float64

- Upsampling:

    >>> d_sr = pd.Series(range(len(d_index)), index=d_index)
    >>> d_sr.vbt.realign(h_index)
    2020-01-01 00:00:00    0.0
    2020-01-01 01:00:00    0.0
    2020-01-01 02:00:00    0.0
    2020-01-01 03:00:00    0.0
    2020-01-01 04:00:00    0.0
    ...                    ...
    2020-01-04 20:00:00    3.0
    2020-01-04 21:00:00    3.0
    2020-01-04 22:00:00    3.0
    2020-01-04 23:00:00    3.0
    2020-01-05 00:00:00    4.0
    Freq: H, Length: 97, dtype: float64

### realign_closing method

    GenericAccessor.realign_closing(
        *args,
        **kwargs
    )

GenericAccessor.realign() but creating a resampler and using the right bound of the source and target index.

Note

The timestamps in the source and target index should denote the open time.

### realign_opening method

    GenericAccessor.realign_opening(
        *args,
        **kwargs
    )

GenericAccessor.realign() but creating a resampler and using the left bound of the source and target index.

### rebase method

    GenericAccessor.rebase(
        base,
        jitted=None,
        chunked=None,
        wrap_kwargs=None
    )

Rebase all series to the given base.

This makes comparing/plotting different series together easier. Will forward and backward fill NaN values.

### reduce class method

    GenericAccessor.reduce(
        reduce_func_nb,
        *args,
        returns_array=False,
        returns_idx=False,
        flatten=False,
        order='C',
        to_index=True,
        broadcast_named_args=None,
        broadcast_kwargs=None,
        template_context=None,
        jitted=None,
        chunked=None,
        wrapper=None,
        group_by=None,
        wrap_kwargs=None
    )

Reduce by column/group.

Set `flatten` to True when working with grouped data to pass a flattened array to `reduce_func_nb`. The order in which to flatten the array can be specified using `order`.

Set `returns_array` to True if `reduce_func_nb` returns an array.

Set `returns_idx` to True if `reduce_func_nb` returns row index/position.

Set `to_index` to True to return labels instead of positions.

For implementation details, see

- reduce_flat_grouped_to_array_nb() if grouped, `returns_array` is True, and `flatten` is True
- reduce_flat_grouped_nb() if grouped, `returns_array` is False, and `flatten` is True
- reduce_grouped_to_array_nb() if grouped, `returns_array` is True, and `flatten` is False
- reduce_grouped_nb() if grouped, `returns_array` is False, and `flatten` is False
- reduce_to_array_nb() if not grouped and `returns_array` is True
- reduce_nb() if not grouped and `returns_array` is False

For implementation details on the meta versions, see

- reduce_grouped_to_array_meta_nb() if grouped and `returns_array` is True
- reduce_grouped_meta_nb() if grouped and `returns_array` is False
- reduce_to_array_meta_nb() if not grouped and `returns_array` is True
- reduce_meta_nb() if not grouped and `returns_array` is False

`reduce_func_nb` can be a string denoting the suffix of a reducing function from vectorbtpro.generic.nb. For example, "sum" will refer to "sum_reduce_nb".

Usage

- Using regular function:

    >>> mean_nb = njit(lambda a: np.nanmean(a))

    >>> df.vbt.reduce(mean_nb)
    a    3.0
    b    3.0
    c    1.8
    Name: reduce, dtype: float64

    >>> argmax_nb = njit(lambda a: np.argmax(a))

    >>> df.vbt.reduce(argmax_nb, returns_idx=True)
    a   2020-01-05
    b   2020-01-01
    c   2020-01-03
    Name: reduce, dtype: datetime64[ns]

    >>> df.vbt.reduce(argmax_nb, returns_idx=True, to_index=False)
    a    4
    b    0
    c    2
    Name: reduce, dtype: int64

    >>> min_max_nb = njit(lambda a: np.array([np.nanmin(a), np.nanmax(a)]))

    >>> df.vbt.reduce(min_max_nb, returns_array=True, wrap_kwargs=dict(name_or_index=['min', 'max']))
         a  b  c
    min  1  1  1
    max  5  5  3

    >>> group_by = pd.Series(['first', 'first', 'second'], name='group')
    >>> df.vbt.reduce(mean_nb, group_by=group_by)
    group
    first     3.0
    second    1.8
    dtype: float64

- Using meta function:

    >>> mean_meta_nb = njit(lambda col, a: np.nanmean(a[:, col]))

    >>> pd.Series.vbt.reduce(
    ...     mean_meta_nb,
    ...     df['a'].vbt.to_2d_array(),
    ...     wrapper=df['a'].vbt.wrapper
    ... )
    3.0

    >>> vbt.pd_acc.reduce(
    ...     mean_meta_nb,
    ...     df.vbt.to_2d_array(),
    ...     wrapper=df.vbt.wrapper
    ... )
    a    3.0
    b    3.0
    c    1.8
    Name: reduce, dtype: float64

    >>> grouped_mean_meta_nb = njit(lambda group_idxs, group, a: np.nanmean(a[:, group_idxs]))

    >>> group_by = pd.Series(['first', 'first', 'second'], name='group')
    >>> vbt.pd_acc.reduce(
    ...     grouped_mean_meta_nb,
    ...     df.vbt.to_2d_array(),
    ...     wrapper=df.vbt.wrapper,
    ...     group_by=group_by
    ... )
    group
    first     3.0
    second    1.8
    Name: reduce, dtype: float64

- Using templates and broadcasting:

    >>> mean_a_b_nb = njit(lambda col, a, b: \
    ...     np.array([np.nanmean(a[:, col]), np.nanmean(b[:, col])]))

    >>> vbt.pd_acc.reduce(
    ...     mean_a_b_nb,
    ...     vbt.Rep('arr1'),
    ...     vbt.Rep('arr2'),
    ...     returns_array=True,
    ...     broadcast_named_args=dict(
    ...         arr1=pd.Series([1, 2, 3, 4, 5], index=df.index),
    ...         arr2=pd.DataFrame([[1, 2, 3]], columns=['a', 'b', 'c'])
    ...     ),
    ...     wrap_kwargs=dict(name_or_index=['arr1', 'arr2'])
    ... )
            a    b    c
    arr1  3.0  3.0  3.0
    arr2  1.0  2.0  3.0

### resample_apply class method

    GenericAccessor.resample_apply(
        rule,
        reduce_func_nb,
        *args,
        use_groupby_apply=False,
        freq=None,
        resample_kwargs=None,
        broadcast_named_args=None,
        broadcast_kwargs=None,
        template_context=None,
        wrapper=None,
        wrap_kwargs=None,
        **kwargs
    )

Resample.

Argument `rule` can be an instance of Resampler, `pandas.core.resample.Resampler`, or any other frequency-like object that can be accepted by `pd.DataFrame.resample` with `resample_kwargs` passed as keyword arguments. If `use_groupby_apply` is True, uses GenericAccessor.groupby_apply() (with some post-processing). Otherwise, uses GenericAccessor.resample_to_index().

Usage

- Using regular function:

    >>> mean_nb = njit(lambda a: np.nanmean(a))

    >>> df.vbt.resample_apply('2d', mean_nb)
                  a    b    c
    2020-01-01  1.5  4.5  1.5
    2020-01-03  3.5  2.5  2.5
    2020-01-05  5.0  1.0  1.0

- Using meta function:

    >>> mean_ratio_meta_nb = njit(lambda idxs, group, col, a, b: \
    ...     np.mean(a[idxs, col]) / np.mean(b[idxs, col]))

    >>> vbt.pd_acc.resample_apply(
    ...     '2d',
    ...     mean_ratio_meta_nb,
    ...     df.vbt.to_2d_array() - 1,
    ...     df.vbt.to_2d_array() + 1,
    ...     wrapper=df.vbt.wrapper
    ... )
                       a         b         c
    2020-01-01  0.200000  0.636364  0.200000
    2020-01-03  0.555556  0.428571  0.428571
    2020-01-05  0.666667  0.000000  0.000000

- Using templates and broadcasting:

    >>> vbt.pd_acc.resample_apply(
    ...     '2d',
    ...     mean_ratio_meta_nb,
    ...     vbt.Rep('a'),
    ...     vbt.Rep('b'),
    ...     broadcast_named_args=dict(
    ...         a=pd.Series([1, 2, 3, 4, 5], index=df.index),
    ...         b=pd.DataFrame([[1, 2, 3]], columns=['a', 'b', 'c'])
    ...     )
    ... )
                  a     b         c
    2020-01-01  1.5  0.75  0.500000
    2020-01-03  3.5  1.75  1.166667
    2020-01-05  5.0  2.50  1.666667

### resample_between_bounds class method

    GenericAccessor.resample_between_bounds(
        target_lbound_index,
        target_rbound_index,
        reduce_func_nb,
        *args,
        closed_lbound=True,
        closed_rbound=False,
        broadcast_named_args=None,
        broadcast_kwargs=None,
        template_context=None,
        jitted=None,
        chunked=None,
        wrapper=None,
        wrap_with_lbound=None,
        wrap_kwargs=None
    )

Resample between target index bounds.

Applies reduce_index_ranges_nb() on index ranges from map_bounds_to_source_ranges_nb().

For details on the meta version, see reduce_index_ranges_meta_nb().

Usage

- Using regular function:

    >>> h_index = pd.date_range('2020-01-01', '2020-01-05', freq='1h')
    >>> d_index = pd.date_range('2020-01-01', '2020-01-05', freq='1d')

    >>> h_sr = pd.Series(range(len(h_index)), index=h_index)
    >>> h_sr.vbt.resample_between_bounds(d_index, d_index.shift(), njit(lambda x: x.mean()))
    2020-01-01    11.5
    2020-01-02    35.5
    2020-01-03    59.5
    2020-01-04    83.5
    2020-01-05    96.0
    Freq: D, dtype: float64

- Using meta function:

    >>> mean_ratio_meta_nb = njit(lambda from_i, to_i, col, a, b: \
    ...     np.mean(a[from_i:to_i][col]) / np.mean(b[from_i:to_i][col]))

    >>> vbt.pd_acc.resample_between_bounds(
    ...     d_index,
    ...     d_index.shift(),
    ...     mean_ratio_meta_nb,
    ...     h_sr.vbt.to_2d_array() - 1,
    ...     h_sr.vbt.to_2d_array() + 1,
    ...     wrapper=h_sr.vbt.wrapper
    ... )
    2020-01-01   -1.000000
    2020-01-02    0.920000
    2020-01-03    0.959184
    2020-01-04    0.972603
    2020-01-05    0.979381
    Freq: D, dtype: float64

- Using templates and broadcasting:

    >>> vbt.pd_acc.resample_between_bounds(
    ...     d_index,
    ...     d_index.shift(),
    ...     mean_ratio_meta_nb,
    ...     vbt.Rep('a'),
    ...     vbt.Rep('b'),
    ...     broadcast_named_args=dict(
    ...         a=h_sr - 1,
    ...         b=h_sr + 1
    ...     )
    ... )
    2020-01-01   -1.000000
    2020-01-02    0.920000
    2020-01-03    0.959184
    2020-01-04    0.972603
    2020-01-05    0.979381
    Freq: D, dtype: float64

### resample_to_index class method

    GenericAccessor.resample_to_index(
        index,
        reduce_func_nb,
        *args,
        freq=None,
        before=False,
        broadcast_named_args=None,
        broadcast_kwargs=None,
        template_context=None,
        jitted=None,
        chunked=None,
        wrapper=None,
        wrap_kwargs=None,
        silence_warnings=None
    )

Resample solely based on target index.

Applies reduce_index_ranges_nb() on index ranges from map_index_to_source_ranges_nb().

For details on the meta version, see reduce_index_ranges_meta_nb().

Usage

- Downsampling:

    >>> h_index = pd.date_range('2020-01-01', '2020-01-05', freq='1h')
    >>> d_index = pd.date_range('2020-01-01', '2020-01-05', freq='1d')

    >>> h_sr = pd.Series(range(len(h_index)), index=h_index)
    >>> h_sr.vbt.resample_to_index(d_index, njit(lambda x: x.mean()))
    2020-01-01    11.5
    2020-01-02    35.5
    2020-01-03    59.5
    2020-01-04    83.5
    2020-01-05    96.0
    Freq: D, dtype: float64

    >>> h_sr.vbt.resample_to_index(d_index, njit(lambda x: x.mean()), before=True)
    2020-01-01     0.0
    2020-01-02    12.5
    2020-01-03    36.5
    2020-01-04    60.5
    2020-01-05    84.5
    Freq: D, dtype: float64

- Upsampling:

    >>> d_sr = pd.Series(range(len(d_index)), index=d_index)
    >>> d_sr.vbt.resample_to_index(h_index, njit(lambda x: x[-1]))
    2020-01-01 00:00:00    0.0
    2020-01-01 01:00:00    NaN
    2020-01-01 02:00:00    NaN
    2020-01-01 03:00:00    NaN
    2020-01-01 04:00:00    NaN
    ...                    ...
    2020-01-04 20:00:00    NaN
    2020-01-04 21:00:00    NaN
    2020-01-04 22:00:00    NaN
    2020-01-04 23:00:00    NaN
    2020-01-05 00:00:00    4.0
    Freq: H, Length: 97, dtype: float64

- Using meta function:

    >>> mean_ratio_meta_nb = njit(lambda from_i, to_i, col, a, b: \
    ...     np.mean(a[from_i:to_i][col]) / np.mean(b[from_i:to_i][col]))

    >>> vbt.pd_acc.resample_to_index(
    ...     d_index,
    ...     mean_ratio_meta_nb,
    ...     h_sr.vbt.to_2d_array() - 1,
    ...     h_sr.vbt.to_2d_array() + 1,
    ...     wrapper=h_sr.vbt.wrapper
    ... )
    2020-01-01   -1.000000
    2020-01-02    0.920000
    2020-01-03    0.959184
    2020-01-04    0.972603
    2020-01-05    0.979381
    Freq: D, dtype: float64

- Using templates and broadcasting:

    >>> vbt.pd_acc.resample_to_index(
    ...     d_index,
    ...     mean_ratio_meta_nb,
    ...     vbt.Rep('a'),
    ...     vbt.Rep('b'),
    ...     broadcast_named_args=dict(
    ...         a=h_sr - 1,
    ...         b=h_sr + 1
    ...     )
    ... )
    2020-01-01   -1.000000
    2020-01-02    0.920000
    2020-01-03    0.959184
    2020-01-04    0.972603
    2020-01-05    0.979381
    Freq: D, dtype: float64

### resolve_mapping method

    GenericAccessor.resolve_mapping(
        mapping=None
    )

Resolve mapping.

Set `mapping` to False to disable mapping completely.

### resolve_self method

    GenericAccessor.resolve_self(
        cond_kwargs=None,
        custom_arg_names=None,
        impacts_caching=True,
        silence_warnings=False
    )

Resolve self.

See Wrapping.resolve_self().

Creates a copy of this instance `mapping` is different in `cond_kwargs`.

### robust_scale method

    GenericAccessor.robust_scale(
        *,
        with_centering=True,
        with_scaling=True,
        quantile_range=(25.0, 75.0),
        copy=True,
        unit_variance=False,
        **kwargs
    )

See `sklearn.preprocessing.RobustScaler`.

### rolling_all method

    GenericAccessor.rolling_all(
        window,
        *,
        jitted=None,
        chunked=None,
        wrap_kwargs=None
    )

See rolling_all_nb().

### rolling_any method

    GenericAccessor.rolling_any(
        window,
        *,
        jitted=None,
        chunked=None,
        wrap_kwargs=None
    )

See rolling_any_nb().

### rolling_apply class method

    GenericAccessor.rolling_apply(
        window,
        reduce_func_nb,
        *args,
        minp=None,
        broadcast_named_args=None,
        broadcast_kwargs=None,
        template_context=None,
        jitted=None,
        chunked=None,
        wrapper=None,
        wrap_kwargs=None
    )

See rolling_reduce_nb() for integer windows and rolling_freq_reduce_nb() for frequency windows.

For details on the meta version, see rolling_reduce_meta_nb() for integer windows and rolling_freq_reduce_meta_nb() for frequency windows.

If `window` is None, it will become an expanding window.

Usage

- Using regular function:

    >>> mean_nb = njit(lambda a: np.nanmean(a))

    >>> df.vbt.rolling_apply(3, mean_nb)
                  a    b         c
    2020-01-01  NaN  NaN       NaN
    2020-01-02  NaN  NaN       NaN
    2020-01-03  2.0  4.0  2.000000
    2020-01-04  3.0  3.0  2.333333
    2020-01-05  4.0  2.0  2.000000

- Using a frequency-based window:

    >>> df.vbt.rolling_apply("3d", mean_nb)
                  a    b         c
    2020-01-01  1.0  5.0  1.000000
    2020-01-02  1.5  4.5  1.500000
    2020-01-03  2.0  4.0  2.000000
    2020-01-04  3.0  3.0  2.333333
    2020-01-05  4.0  2.0  2.000000

- Using meta function:

    >>> mean_ratio_meta_nb = njit(lambda from_i, to_i, col, a, b: \
    ...     np.mean(a[from_i:to_i, col]) / np.mean(b[from_i:to_i, col]))

    >>> vbt.pd_acc.rolling_apply(
    ...     3,
    ...     mean_ratio_meta_nb,
    ...     df.vbt.to_2d_array() - 1,
    ...     df.vbt.to_2d_array() + 1,
    ...     wrapper=df.vbt.wrapper,
    ... )
                       a         b         c
    2020-01-01       NaN       NaN       NaN
    2020-01-02       NaN       NaN       NaN
    2020-01-03  0.333333  0.600000  0.333333
    2020-01-04  0.500000  0.500000  0.400000
    2020-01-05  0.600000  0.333333  0.333333

- Using templates and broadcasting:

    >>> vbt.pd_acc.rolling_apply(
    ...     2,
    ...     mean_ratio_meta_nb,
    ...     vbt.Rep('a'),
    ...     vbt.Rep('b'),
    ...     broadcast_named_args=dict(
    ...         a=pd.Series([1, 2, 3, 4, 5], index=df.index),
    ...         b=pd.DataFrame([[1, 2, 3]], columns=['a', 'b', 'c'])
    ...     )
    ... )
                  a     b         c
    2020-01-01  NaN   NaN       NaN
    2020-01-02  1.5  0.75  0.500000
    2020-01-03  2.5  1.25  0.833333
    2020-01-04  3.5  1.75  1.166667
    2020-01-05  4.5  2.25  1.500000

### rolling_corr method

    GenericAccessor.rolling_corr(
        other,
        window,
        minp=None,
        broadcast_kwargs=None,
        jitted=None,
        chunked=None,
        wrap_kwargs=None
    )

See rolling_corr_nb().

### rolling_cov method

    GenericAccessor.rolling_cov(
        other,
        window,
        minp=None,
        ddof=1,
        broadcast_kwargs=None,
        jitted=None,
        chunked=None,
        wrap_kwargs=None
    )

See rolling_cov_nb().

### rolling_idxmax method

    GenericAccessor.rolling_idxmax(
        window,
        minp=None,
        local=False,
        jitted=None,
        chunked=None,
        wrap_kwargs=None
    )

See rolling_argmax_nb().

### rolling_idxmin method

    GenericAccessor.rolling_idxmin(
        window,
        minp=None,
        local=False,
        jitted=None,
        chunked=None,
        wrap_kwargs=None
    )

See rolling_argmin_nb().

### rolling_max method

    GenericAccessor.rolling_max(
        window,
        minp=None,
        *,
        jitted=None,
        chunked=None,
        wrap_kwargs=None
    )

See rolling_max_nb().

### rolling_mean method

    GenericAccessor.rolling_mean(
        window,
        minp=None,
        jitted=None,
        chunked=None,
        wrap_kwargs=None
    )

See rolling_mean_nb().

### rolling_min method

    GenericAccessor.rolling_min(
        window,
        minp=None,
        *,
        jitted=None,
        chunked=None,
        wrap_kwargs=None
    )

See rolling_min_nb().

### rolling_ols method

    GenericAccessor.rolling_ols(
        other,
        window,
        minp=None,
        broadcast_kwargs=None,
        jitted=None,
        chunked=None,
        wrap_kwargs=None
    )

See rolling_ols_nb().

Returns two arrays: slope and intercept.

### rolling_pattern_similarity method

    GenericAccessor.rolling_pattern_similarity(
        pattern,
        window=None,
        max_window=None,
        row_select_prob=1.0,
        window_select_prob=1.0,
        interp_mode='mixed',
        rescale_mode='minmax',
        vmin=nan,
        vmax=nan,
        pmin=nan,
        pmax=nan,
        invert=False,
        error_type='absolute',
        distance_measure='mae',
        max_error=nan,
        max_error_interp_mode=None,
        max_error_as_maxdist=False,
        max_error_strict=False,
        min_pct_change=nan,
        max_pct_change=nan,
        min_similarity=nan,
        minp=None,
        jitted=None,
        chunked=None,
        wrap_kwargs=None
    )

See rolling_pattern_similarity_nb().

### rolling_prod method

    GenericAccessor.rolling_prod(
        window,
        minp=None,
        *,
        jitted=None,
        chunked=None,
        wrap_kwargs=None
    )

See rolling_prod_nb().

### rolling_rank method

    GenericAccessor.rolling_rank(
        window,
        minp=None,
        pct=False,
        jitted=None,
        chunked=None,
        wrap_kwargs=None
    )

See rolling_rank_nb().

### rolling_std method

    GenericAccessor.rolling_std(
        window,
        minp=None,
        ddof=1,
        jitted=None,
        chunked=None,
        wrap_kwargs=None
    )

See rolling_std_nb().

### rolling_sum method

    GenericAccessor.rolling_sum(
        window,
        minp=None,
        *,
        jitted=None,
        chunked=None,
        wrap_kwargs=None
    )

See rolling_sum_nb().

### rolling_zscore method

    GenericAccessor.rolling_zscore(
        window,
        minp=None,
        ddof=1,
        jitted=None,
        chunked=None,
        wrap_kwargs=None
    )

See rolling_zscore_nb().

### row_apply class method

    GenericAccessor.row_apply(
        *args,
        **kwargs
    )

GenericAccessor.apply_along_axis() with `axis=0`.

### scale method

    GenericAccessor.scale(
        *,
        copy=True,
        with_mean=True,
        with_std=True,
        **kwargs
    )

See `sklearn.preprocessing.StandardScaler`.

### scatterplot method

    GenericAccessor.scatterplot(
        column=None,
        **kwargs
    )

GenericAccessor.plot() with 'markers' mode.

Usage

    >>> df.vbt.scatterplot().show()

### shuffle method

    GenericAccessor.shuffle(
        seed=None,
        *,
        jitted=None,
        wrap_kwargs=None
    )

See shuffle_nb().

### squeeze_grouped class method

    GenericAccessor.squeeze_grouped(
        squeeze_func_nb,
        *args,
        broadcast_named_args=None,
        broadcast_kwargs=None,
        template_context=None,
        jitted=None,
        chunked=None,
        wrapper=None,
        group_by=None,
        wrap_kwargs=None
    )

Squeeze each group of columns into a single column.

See squeeze_grouped_nb(). For details on the meta version, see squeeze_grouped_meta_nb().

Usage

- Using regular function:

    >>> mean_nb = njit(lambda a: np.nanmean(a))

    >>> group_by = pd.Series(['first', 'first', 'second'], name='group')
    >>> df.vbt.squeeze_grouped(mean_nb, group_by=group_by)
    group       first  second
    2020-01-01    3.0     1.0
    2020-01-02    3.0     2.0
    2020-01-03    3.0     3.0
    2020-01-04    3.0     2.0
    2020-01-05    3.0     1.0

- Using meta function:

    >>> mean_ratio_meta_nb = njit(lambda i, group_idxs, group, a, b: \
    ...     np.mean(a[i][group_idxs]) / np.mean(b[i][group_idxs]))

    >>> vbt.pd_acc.squeeze_grouped(
    ...     mean_ratio_meta_nb,
    ...     df.vbt.to_2d_array() - 1,
    ...     df.vbt.to_2d_array() + 1,
    ...     wrapper=df.vbt.wrapper,
    ...     group_by=group_by
    ... )
    group       first    second
    2020-01-01    0.5  0.000000
    2020-01-02    0.5  0.333333
    2020-01-03    0.5  0.500000
    2020-01-04    0.5  0.333333
    2020-01-05    0.5  0.000000

- Using templates and broadcasting:

    >>> vbt.pd_acc.squeeze_grouped(
    ...     mean_ratio_meta_nb,
    ...     vbt.Rep('a'),
    ...     vbt.Rep('b'),
    ...     broadcast_named_args=dict(
    ...         a=pd.Series([1, 2, 3, 4, 5], index=df.index),
    ...         b=pd.DataFrame([[1, 2, 3]], columns=['a', 'b', 'c'])
    ...     ),
    ...     group_by=[0, 0, 1]
    ... )
                       0         1
    2020-01-01  0.666667  0.333333
    2020-01-02  1.333333  0.666667
    2020-01-03  2.000000  1.000000
    2020-01-04  2.666667  1.333333
    2020-01-05  3.333333  1.666667

### stats_defaults property

Defaults for StatsBuilderMixin.stats().

Merges StatsBuilderMixin.stats_defaults and `stats` from generic.

### std method

    GenericAccessor.std(
        ddof=1,
        use_jitted=None,
        jitted=None,
        chunked=None,
        group_by=None,
        wrap_kwargs=None
    )

Return standard deviation of non-NaN elements.

### subplots class variable

Subplots supported by GenericAccessor.

    HybridConfig(
        plot=dict(
            check_is_not_grouped=True,
            plot_func='plot',
            pass_trace_names=False,
            tags='generic'
        )
    )

Returns `GenericAccessor._subplots`, which gets (hybrid-) copied upon creation of each instance. Thus, changing this config won't affect the class.

To change subplots, you can either change the config in-place, override this property, or overwrite the instance variable `GenericAccessor._subplots`.

### sum method

    GenericAccessor.sum(
        use_jitted=None,
        jitted=None,
        chunked=None,
        group_by=None,
        wrap_kwargs=None
    )

Return sum of non-NaN elements.

### to_daily_log_returns method

    GenericAccessor.to_daily_log_returns(
        **kwargs
    )

Get daily log returns of this object.

### to_daily_returns method

    GenericAccessor.to_daily_returns(
        **kwargs
    )

Get daily returns of this object.

### to_log_returns method

    GenericAccessor.to_log_returns(
        **kwargs
    )

Get log returns of this object.

### to_mapped method

    GenericAccessor.to_mapped(
        dropna=True,
        dtype=None,
        group_by=None,
        **kwargs
    )

Convert this object into an instance of MappedArray.

### to_returns method

    GenericAccessor.to_returns(
        **kwargs
    )

Get returns of this object.

### transform method

    GenericAccessor.transform(
        transformer,
        wrap_kwargs=None,
        **kwargs
    )

Transform using a transformer.

A transformer can be any class instance that has `transform` and `fit_transform` methods, ideally subclassing `sklearn.base.TransformerMixin` and `sklearn.base.BaseEstimator`.

Will fit `transformer` if not fitted.

`**kwargs` are passed to the `transform` or `fit_transform` method.

Usage

    >>> from sklearn.preprocessing import MinMaxScaler

    >>> df.vbt.transform(MinMaxScaler((-1, 1)))
                  a    b    c
    2020-01-01 -1.0  1.0 -1.0
    2020-01-02 -0.5  0.5  0.0
    2020-01-03  0.0  0.0  1.0
    2020-01-04  0.5 -0.5  0.0
    2020-01-05  1.0 -1.0 -1.0

    >>> fitted_scaler = MinMaxScaler((-1, 1)).fit(np.array([[2], [4]]))
    >>> df.vbt.transform(fitted_scaler)
                  a    b    c
    2020-01-01 -2.0  2.0 -2.0
    2020-01-02 -1.0  1.0 -1.0
    2020-01-03  0.0  0.0  0.0
    2020-01-04  1.0 -1.0 -1.0
    2020-01-05  2.0 -2.0 -2.0

### ts_heatmap method

    GenericAccessor.ts_heatmap(
        column=None,
        is_y_category=True,
        **kwargs
    )

Heatmap of time-series data.

### value_counts method

    GenericAccessor.value_counts(
        axis=1,
        normalize=False,
        sort_uniques=True,
        sort=False,
        ascending=False,
        dropna=False,
        group_by=None,
        mapping=None,
        incl_all_keys=False,
        jitted=None,
        chunked=None,
        wrap_kwargs=None,
        **kwargs
    )

Return a Series/DataFrame containing counts of unique values.

Args

`axis` :`int`
  0 - counts per row, 1 - counts per column, and -1 - counts across the whole object.
`normalize` :`bool`
  Whether to return the relative frequencies of the unique values.
`sort_uniques` :`bool`
  Whether to sort uniques.
`sort` :`bool`
  Whether to sort by frequency.
`ascending` :`bool`
  Whether to sort in ascending order.
`dropna` :`bool`
  Whether to exclude counts of NaN.
`group_by` :`any`

  Group or ungroup columns.

  See Grouper.

`mapping` :`mapping_like`
  Mapping of values to labels.
`incl_all_keys` :`bool`
  Whether to include all mapping keys, no only those that are present in the array.
`jitted` :`any`
  Whether to JIT-compile value_counts_nb() or options.
`chunked` :`any`

  Whether to chunk value_counts_nb() or options.

  See resolve_chunked().

`wrap_kwargs` :`dict`
  Keyword arguments passed to ArrayWrapper.wrap().
`**kwargs`
  Keyword arguments passed to apply_mapping().

Usage

    >>> df.vbt.value_counts()
       a  b  c
    1  1  1  2
    2  1  1  2
    3  1  1  1
    4  1  1  0
    5  1  1  0

    >>> df.vbt.value_counts(axis=-1)
    1    4
    2    4
    3    3
    4    2
    5    2
    Name: value_counts, dtype: int64

    >>> mapping = {x: 'test_' + str(x) for x in pd.unique(df.values.flatten())}
    >>> df.vbt.value_counts(mapping=mapping)
            a  b  c
    test_1  1  1  2
    test_2  1  1  2
    test_3  1  1  1
    test_4  1  1  0
    test_5  1  1  0

    >>> sr = pd.Series([1, 2, 2, 3, 3, 3, np.nan])
    >>> sr.vbt.value_counts(mapping=mapping)
    test_1    1
    test_2    2
    test_3    3
    NaN       1
    dtype: int64

    >>> sr.vbt.value_counts(mapping=mapping, dropna=True)
    test_1    1
    test_2    2
    test_3    3
    dtype: int64

    >>> sr.vbt.value_counts(mapping=mapping, sort=True)
    test_3    3
    test_2    2
    test_1    1
    NaN       1
    dtype: int64

    >>> sr.vbt.value_counts(mapping=mapping, sort=True, ascending=True)
    test_1    1
    NaN       1
    test_2    2
    test_3    3
    dtype: int64

    >>> sr.vbt.value_counts(mapping=mapping, incl_all_keys=True)
    test_1    1
    test_2    2
    test_3    3
    test_4    0
    test_5    0
    NaN       1
    dtype: int64

### vidya method

    GenericAccessor.vidya(
        window,
        minp=None,
        jitted=None,
        chunked=None,
        wrap_kwargs=None
    )

See vidya_nb().

### volume method

    GenericAccessor.volume(
        column=None,
        x_level=None,
        y_level=None,
        z_level=None,
        x_labels=None,
        y_labels=None,
        z_labels=None,
        slider_level=None,
        slider_labels=None,
        active=0,
        scene_name='scene',
        fillna=None,
        fig=None,
        return_fig=True,
        **kwargs
    )

Create a 3D volume figure based on object's multi-index and values.

If multi-index contains more than three levels or you want them in specific order, pass `x_level`, `y_level`, and `z_level`, each (`int` if index or `str` if name) corresponding to an axis of the volume. Optionally, pass `slider_level` to use a level as a slider.

Creates Volume and returns the figure.

Usage

    >>> multi_index = pd.MultiIndex.from_tuples([
    ...     (1, 1, 1),
    ...     (2, 2, 2),
    ...     (3, 3, 3)
    ... ])
    >>> sr = pd.Series(np.arange(len(multi_index)), index=multi_index)
    >>> sr
    1  1  1    0
    2  2  2    1
    3  3  3    2
    dtype: int64

    >>> sr.vbt.volume().show()

### wm_mean method

    GenericAccessor.wm_mean(
        span,
        minp=None,
        jitted=None,
        chunked=None,
        wrap_kwargs=None
    )

See wm_mean_nb().

### wwm_mean method

    GenericAccessor.wwm_mean(
        period,
        minp=0,
        adjust=True,
        jitted=None,
        chunked=None,
        wrap_kwargs=None
    )

See wwm_mean_nb().

### wwm_std method

    GenericAccessor.wwm_std(
        period,
        minp=0,
        adjust=True,
        jitted=None,
        chunked=None,
        wrap_kwargs=None
    )

See wwm_std_nb().

### zscore method

    GenericAccessor.zscore(
        **kwargs
    )

Compute z-score using `sklearn.preprocessing.StandardScaler`.

## GenericDFAccessor class

    GenericDFAccessor(
        wrapper,
        obj=None,
        mapping=None,
        **kwargs
    )

Accessor on top of data of any type. For DataFrames only.

Accessible via `pd.DataFrame.vbt`.

Superclasses

- Analyzable
- AttrResolverMixin
- BaseAccessor
- BaseDFAccessor
- Cacheable
- Chainable
- Comparable
- Configured
- ExtPandasIndexer
- GenericAccessor
- HasSettings
- IndexingBase
- PandasIndexer
- Pickleable
- PlotsBuilderMixin
- Prettified
- StatsBuilderMixin
- Wrapping

Inherited members

- AttrResolverMixin.deep_getattr()
- AttrResolverMixin.post_resolve_attr()
- AttrResolverMixin.pre_resolve_attr()
- AttrResolverMixin.resolve_attr()
- AttrResolverMixin.resolve_shortcut_attr()
- BaseAccessor.align()
- BaseAccessor.align_to()
- BaseAccessor.apply()
- BaseAccessor.apply_and_concat()
- BaseAccessor.apply_on_index()
- BaseAccessor.broadcast()
- BaseAccessor.broadcast_combs()
- BaseAccessor.broadcast_to()
- BaseAccessor.column_stack()
- BaseAccessor.combine()
- BaseAccessor.concat()
- BaseAccessor.cross()
- BaseAccessor.cross()
- BaseAccessor.cross_with()
- BaseAccessor.drop_duplicate_levels()
- BaseAccessor.drop_levels()
- BaseAccessor.drop_redundant_levels()
- BaseAccessor.empty()
- BaseAccessor.empty_like()
- BaseAccessor.eval()
- BaseAccessor.get()
- BaseAccessor.indexing_func()
- BaseAccessor.indexing_setter_func()
- BaseAccessor.make_symmetric()
- BaseAccessor.rename_levels()
- BaseAccessor.repeat()
- BaseAccessor.resolve_column_stack_kwargs()
- BaseAccessor.resolve_row_stack_kwargs()
- BaseAccessor.resolve_shape()
- BaseAccessor.row_stack()
- BaseAccessor.select_levels()
- BaseAccessor.set()
- BaseAccessor.set_between()
- BaseAccessor.stack_index()
- BaseAccessor.tile()
- BaseAccessor.to_1d_array()
- BaseAccessor.to_2d_array()
- BaseAccessor.to_dict()
- BaseAccessor.unstack_to_array()
- BaseAccessor.unstack_to_df()
- Cacheable.get_ca_setup()
- Chainable.pipe()
- Configured.copy()
- Configured.equals()
- Configured.get_writeable_attrs()
- Configured.prettify()
- Configured.replace()
- Configured.resolve_merge_kwargs()
- Configured.update_config()
- GenericAccessor.ago()
- GenericAccessor.all_ago()
- GenericAccessor.any_ago()
- GenericAccessor.apply_along_axis()
- GenericAccessor.apply_and_reduce()
- GenericAccessor.apply_mapping()
- GenericAccessor.areaplot()
- GenericAccessor.barplot()
- GenericAccessor.bfill()
- GenericAccessor.binarize()
- GenericAccessor.boxplot()
- GenericAccessor.bshift()
- GenericAccessor.cls_dir
- GenericAccessor.column_apply()
- GenericAccessor.column_only_select
- GenericAccessor.config
- GenericAccessor.corr()
- GenericAccessor.count()
- GenericAccessor.cov()
- GenericAccessor.crossed_above()
- GenericAccessor.crossed_below()
- GenericAccessor.cumprod()
- GenericAccessor.cumsum()
- GenericAccessor.demean()
- GenericAccessor.describe()
- GenericAccessor.df_accessor_cls
- GenericAccessor.diff()
- GenericAccessor.digitize()
- GenericAccessor.drawdown()
- GenericAccessor.drawdowns
- GenericAccessor.ewm_mean()
- GenericAccessor.ewm_std()
- GenericAccessor.expanding_apply()
- GenericAccessor.expanding_corr()
- GenericAccessor.expanding_cov()
- GenericAccessor.expanding_idxmax()
- GenericAccessor.expanding_idxmin()
- GenericAccessor.expanding_max()
- GenericAccessor.expanding_mean()
- GenericAccessor.expanding_min()
- GenericAccessor.expanding_ols()
- GenericAccessor.expanding_rank()
- GenericAccessor.expanding_std()
- GenericAccessor.expanding_zscore()
- GenericAccessor.fbfill()
- GenericAccessor.ffill()
- GenericAccessor.fillna()
- GenericAccessor.find_pattern()
- GenericAccessor.flatten_grouped()
- GenericAccessor.fshift()
- GenericAccessor.get_drawdowns()
- GenericAccessor.get_ranges()
- GenericAccessor.group_select
- GenericAccessor.groupby_apply()
- GenericAccessor.groupby_transform()
- GenericAccessor.heatmap()
- GenericAccessor.histplot()
- GenericAccessor.idxmax()
- GenericAccessor.idxmin()
- GenericAccessor.iloc
- GenericAccessor.indexing_kwargs
- GenericAccessor.lineplot()
- GenericAccessor.loc
- GenericAccessor.ma()
- GenericAccessor.map()
- GenericAccessor.mapping
- GenericAccessor.max()
- GenericAccessor.maxabs_scale()
- GenericAccessor.mean()
- GenericAccessor.median()
- GenericAccessor.min()
- GenericAccessor.minmax_scale()
- GenericAccessor.msd()
- GenericAccessor.normalize()
- GenericAccessor.obj
- GenericAccessor.overlay_with_heatmap()
- GenericAccessor.pct_change()
- GenericAccessor.plot()
- GenericAccessor.plot_against()
- GenericAccessor.plot_pattern()
- GenericAccessor.plots_defaults
- GenericAccessor.power_transform()
- GenericAccessor.product()
- GenericAccessor.proximity_apply()
- GenericAccessor.qqplot()
- GenericAccessor.quantile_transform()
- GenericAccessor.range_only_select
- GenericAccessor.ranges
- GenericAccessor.rank()
- GenericAccessor.realign()
- GenericAccessor.realign_closing()
- GenericAccessor.realign_opening()
- GenericAccessor.rebase()
- GenericAccessor.rec_state
- GenericAccessor.reduce()
- GenericAccessor.resample_apply()
- GenericAccessor.resample_between_bounds()
- GenericAccessor.resample_to_index()
- GenericAccessor.resolve_mapping()
- GenericAccessor.resolve_self()
- GenericAccessor.robust_scale()
- GenericAccessor.rolling_all()
- GenericAccessor.rolling_any()
- GenericAccessor.rolling_apply()
- GenericAccessor.rolling_corr()
- GenericAccessor.rolling_cov()
- GenericAccessor.rolling_idxmax()
- GenericAccessor.rolling_idxmin()
- GenericAccessor.rolling_max()
- GenericAccessor.rolling_mean()
- GenericAccessor.rolling_min()
- GenericAccessor.rolling_ols()
- GenericAccessor.rolling_pattern_similarity()
- GenericAccessor.rolling_prod()
- GenericAccessor.rolling_rank()
- GenericAccessor.rolling_std()
- GenericAccessor.rolling_sum()
- GenericAccessor.rolling_zscore()
- GenericAccessor.row_apply()
- GenericAccessor.scale()
- GenericAccessor.scatterplot()
- GenericAccessor.self_aliases
- GenericAccessor.shuffle()
- GenericAccessor.squeeze_grouped()
- GenericAccessor.sr_accessor_cls
- GenericAccessor.stats_defaults
- GenericAccessor.std()
- GenericAccessor.sum()
- GenericAccessor.to_daily_log_returns()
- GenericAccessor.to_daily_returns()
- GenericAccessor.to_log_returns()
- GenericAccessor.to_mapped()
- GenericAccessor.to_returns()
- GenericAccessor.transform()
- GenericAccessor.ts_heatmap()
- GenericAccessor.value_counts()
- GenericAccessor.vidya()
- GenericAccessor.volume()
- GenericAccessor.wm_mean()
- GenericAccessor.wrapper
- GenericAccessor.wwm_mean()
- GenericAccessor.wwm_std()
- GenericAccessor.xloc
- GenericAccessor.zscore()
- HasSettings.get_path_setting()
- HasSettings.get_path_settings()
- HasSettings.get_setting()
- HasSettings.get_settings()
- HasSettings.has_path_setting()
- HasSettings.has_path_settings()
- HasSettings.has_setting()
- HasSettings.has_settings()
- HasSettings.reset_settings()
- HasSettings.resolve_setting()
- HasSettings.resolve_settings_paths()
- HasSettings.set_settings()
- PandasIndexer.xs()
- Pickleable.decode_config()
- Pickleable.decode_config_node()
- Pickleable.dumps()
- Pickleable.encode_config()
- Pickleable.encode_config_node()
- Pickleable.file_exists()
- Pickleable.getsize()
- Pickleable.load()
- Pickleable.loads()
- Pickleable.modify_state()
- Pickleable.resolve_file_path()
- Pickleable.save()
- PlotsBuilderMixin.build_subplots_doc()
- PlotsBuilderMixin.override_subplots_doc()
- PlotsBuilderMixin.plots()
- StatsBuilderMixin.build_metrics_doc()
- StatsBuilderMixin.override_metrics_doc()
- StatsBuilderMixin.stats()
- Wrapping.regroup()
- Wrapping.resample()
- Wrapping.resolve_stack_kwargs()
- Wrapping.select_col()
- Wrapping.select_col_from_obj()
- Wrapping.split()

Subclasses

- OHLCVDFAccessor
- ReturnsDFAccessor
- SignalsDFAccessor
- Vbt_DFAccessor

### band method

    GenericDFAccessor.band(
        band_name,
        return_meta=False
    )

Calculate the band by its name.

Examples for the band name:

- "50%": 50th quantile
- "Q=50%": 50th quantile
- "Q=0.5": 50th quantile
- "Z=1.96": Z-score of 1.96
- "P=95%": One-tailed significance level of 0.95 (translated into z-score)
- "P=0.95": One-tailed significance level of 0.95 (translated into z-score)
- "median": Median (50th quantile)
- "mean": Mean across all columns
- "min": Min across all columns
- "max": Max across all columns
- "lowest": Column with the lowest final value
- "highest": Column with the highest final value

### plot_projections method

    GenericDFAccessor.plot_projections(
        plot_projections=True,
        plot_bands=True,
        plot_lower=True,
        plot_middle=True,
        plot_upper=True,
        plot_aux_middle=True,
        plot_fill=True,
        colorize=True,
        rename_levels=None,
        projection_trace_kwargs=None,
        upper_trace_kwargs=None,
        middle_trace_kwargs=None,
        lower_trace_kwargs=None,
        aux_middle_trace_kwargs=None,
        add_trace_kwargs=None,
        fig=None,
        **layout_kwargs
    )

Plot a DataFrame where each column is a projection.

If `plot_projections` is True, will plot each projection as a semi-transparent line.

The arguments `plot_lower`, `plot_middle`, `plot_aux_middle`, and `plot_upper` represent bands and accept the following:

- True: Plot the band using the default quantile (20/50/80)
- False: Do not plot the band
- callable: Custom function that accepts DataFrame and reduces it across columns
- For other options see GenericDFAccessor.band()

Note

When providing z-scores, the upper should be positive, the middle should be "mean", and the lower should be negative. When providing significance levels, the middle should be "mean", while the lower should be positive and lower than the upper, for example, 25% and 75%.

Argument `colorize` allows the following values:

- False: Do not colorize
- True or "median": Colorize by median
- "mean": Colorize by mean
- "last": Colorize by last value
- callable: Custom function that accepts (rebased to 0) Series/DataFrame with nans already dropped and reduces it across rows

Colorization is performed by mapping the metric value of the band to the range between the minimum and maximum value across all projections where 0 is always the middle point. If none of the bands is plotted, projections got colorized. Otherwise, projections stay gray.

Usage

    >>> df = pd.DataFrame({
    ...     0: [10, 11, 12, 11, 10],
    ...     1: [10, 12, 14, np.nan, np.nan],
    ...     2: [10, 12, 11, 12, np.nan],
    ...     3: [10, 9, 8, 9, 8],
    ...     4: [10, 11, np.nan, np.nan, np.nan],
    ... })
    >>> df.vbt.plot_projections().show()

## GenericSRAccessor class

    GenericSRAccessor(
        wrapper,
        obj=None,
        mapping=None,
        **kwargs
    )

Accessor on top of data of any type. For Series only.

Accessible via `pd.Series.vbt`.

Superclasses

- Analyzable
- AttrResolverMixin
- BaseAccessor
- BaseSRAccessor
- Cacheable
- Chainable
- Comparable
- Configured
- ExtPandasIndexer
- GenericAccessor
- HasSettings
- IndexingBase
- PandasIndexer
- Pickleable
- PlotsBuilderMixin
- Prettified
- StatsBuilderMixin
- Wrapping

Inherited members

- AttrResolverMixin.deep_getattr()
- AttrResolverMixin.post_resolve_attr()
- AttrResolverMixin.pre_resolve_attr()
- AttrResolverMixin.resolve_attr()
- AttrResolverMixin.resolve_shortcut_attr()
- BaseAccessor.align()
- BaseAccessor.align_to()
- BaseAccessor.apply()
- BaseAccessor.apply_and_concat()
- BaseAccessor.apply_on_index()
- BaseAccessor.broadcast()
- BaseAccessor.broadcast_combs()
- BaseAccessor.broadcast_to()
- BaseAccessor.column_stack()
- BaseAccessor.combine()
- BaseAccessor.concat()
- BaseAccessor.cross()
- BaseAccessor.cross()
- BaseAccessor.cross_with()
- BaseAccessor.drop_duplicate_levels()
- BaseAccessor.drop_levels()
- BaseAccessor.drop_redundant_levels()
- BaseAccessor.empty()
- BaseAccessor.empty_like()
- BaseAccessor.eval()
- BaseAccessor.get()
- BaseAccessor.indexing_func()
- BaseAccessor.indexing_setter_func()
- BaseAccessor.make_symmetric()
- BaseAccessor.rename_levels()
- BaseAccessor.repeat()
- BaseAccessor.resolve_column_stack_kwargs()
- BaseAccessor.resolve_row_stack_kwargs()
- BaseAccessor.resolve_shape()
- BaseAccessor.row_stack()
- BaseAccessor.select_levels()
- BaseAccessor.set()
- BaseAccessor.set_between()
- BaseAccessor.stack_index()
- BaseAccessor.tile()
- BaseAccessor.to_1d_array()
- BaseAccessor.to_2d_array()
- BaseAccessor.to_dict()
- BaseAccessor.unstack_to_array()
- BaseAccessor.unstack_to_df()
- Cacheable.get_ca_setup()
- Chainable.pipe()
- Configured.copy()
- Configured.equals()
- Configured.get_writeable_attrs()
- Configured.prettify()
- Configured.replace()
- Configured.resolve_merge_kwargs()
- Configured.update_config()
- GenericAccessor.ago()
- GenericAccessor.all_ago()
- GenericAccessor.any_ago()
- GenericAccessor.apply_along_axis()
- GenericAccessor.apply_and_reduce()
- GenericAccessor.apply_mapping()
- GenericAccessor.areaplot()
- GenericAccessor.barplot()
- GenericAccessor.bfill()
- GenericAccessor.binarize()
- GenericAccessor.boxplot()
- GenericAccessor.bshift()
- GenericAccessor.cls_dir
- GenericAccessor.column_apply()
- GenericAccessor.column_only_select
- GenericAccessor.config
- GenericAccessor.corr()
- GenericAccessor.count()
- GenericAccessor.cov()
- GenericAccessor.crossed_above()
- GenericAccessor.crossed_below()
- GenericAccessor.cumprod()
- GenericAccessor.cumsum()
- GenericAccessor.demean()
- GenericAccessor.describe()
- GenericAccessor.df_accessor_cls
- GenericAccessor.diff()
- GenericAccessor.digitize()
- GenericAccessor.drawdown()
- GenericAccessor.drawdowns
- GenericAccessor.ewm_mean()
- GenericAccessor.ewm_std()
- GenericAccessor.expanding_apply()
- GenericAccessor.expanding_corr()
- GenericAccessor.expanding_cov()
- GenericAccessor.expanding_idxmax()
- GenericAccessor.expanding_idxmin()
- GenericAccessor.expanding_max()
- GenericAccessor.expanding_mean()
- GenericAccessor.expanding_min()
- GenericAccessor.expanding_ols()
- GenericAccessor.expanding_rank()
- GenericAccessor.expanding_std()
- GenericAccessor.expanding_zscore()
- GenericAccessor.fbfill()
- GenericAccessor.ffill()
- GenericAccessor.fillna()
- GenericAccessor.find_pattern()
- GenericAccessor.flatten_grouped()
- GenericAccessor.fshift()
- GenericAccessor.get_drawdowns()
- GenericAccessor.get_ranges()
- GenericAccessor.group_select
- GenericAccessor.groupby_apply()
- GenericAccessor.groupby_transform()
- GenericAccessor.heatmap()
- GenericAccessor.histplot()
- GenericAccessor.idxmax()
- GenericAccessor.idxmin()
- GenericAccessor.iloc
- GenericAccessor.indexing_kwargs
- GenericAccessor.lineplot()
- GenericAccessor.loc
- GenericAccessor.ma()
- GenericAccessor.map()
- GenericAccessor.mapping
- GenericAccessor.max()
- GenericAccessor.maxabs_scale()
- GenericAccessor.mean()
- GenericAccessor.median()
- GenericAccessor.min()
- GenericAccessor.minmax_scale()
- GenericAccessor.msd()
- GenericAccessor.normalize()
- GenericAccessor.obj
- GenericAccessor.overlay_with_heatmap()
- GenericAccessor.pct_change()
- GenericAccessor.plot()
- GenericAccessor.plot_against()
- GenericAccessor.plot_pattern()
- GenericAccessor.plots_defaults
- GenericAccessor.power_transform()
- GenericAccessor.product()
- GenericAccessor.proximity_apply()
- GenericAccessor.qqplot()
- GenericAccessor.quantile_transform()
- GenericAccessor.range_only_select
- GenericAccessor.ranges
- GenericAccessor.rank()
- GenericAccessor.realign()
- GenericAccessor.realign_closing()
- GenericAccessor.realign_opening()
- GenericAccessor.rebase()
- GenericAccessor.rec_state
- GenericAccessor.reduce()
- GenericAccessor.resample_apply()
- GenericAccessor.resample_between_bounds()
- GenericAccessor.resample_to_index()
- GenericAccessor.resolve_mapping()
- GenericAccessor.resolve_self()
- GenericAccessor.robust_scale()
- GenericAccessor.rolling_all()
- GenericAccessor.rolling_any()
- GenericAccessor.rolling_apply()
- GenericAccessor.rolling_corr()
- GenericAccessor.rolling_cov()
- GenericAccessor.rolling_idxmax()
- GenericAccessor.rolling_idxmin()
- GenericAccessor.rolling_max()
- GenericAccessor.rolling_mean()
- GenericAccessor.rolling_min()
- GenericAccessor.rolling_ols()
- GenericAccessor.rolling_pattern_similarity()
- GenericAccessor.rolling_prod()
- GenericAccessor.rolling_rank()
- GenericAccessor.rolling_std()
- GenericAccessor.rolling_sum()
- GenericAccessor.rolling_zscore()
- GenericAccessor.row_apply()
- GenericAccessor.scale()
- GenericAccessor.scatterplot()
- GenericAccessor.self_aliases
- GenericAccessor.shuffle()
- GenericAccessor.squeeze_grouped()
- GenericAccessor.sr_accessor_cls
- GenericAccessor.stats_defaults
- GenericAccessor.std()
- GenericAccessor.sum()
- GenericAccessor.to_daily_log_returns()
- GenericAccessor.to_daily_returns()
- GenericAccessor.to_log_returns()
- GenericAccessor.to_mapped()
- GenericAccessor.to_returns()
- GenericAccessor.transform()
- GenericAccessor.ts_heatmap()
- GenericAccessor.value_counts()
- GenericAccessor.vidya()
- GenericAccessor.volume()
- GenericAccessor.wm_mean()
- GenericAccessor.wrapper
- GenericAccessor.wwm_mean()
- GenericAccessor.wwm_std()
- GenericAccessor.xloc
- GenericAccessor.zscore()
- HasSettings.get_path_setting()
- HasSettings.get_path_settings()
- HasSettings.get_setting()
- HasSettings.get_settings()
- HasSettings.has_path_setting()
- HasSettings.has_path_settings()
- HasSettings.has_setting()
- HasSettings.has_settings()
- HasSettings.reset_settings()
- HasSettings.resolve_setting()
- HasSettings.resolve_settings_paths()
- HasSettings.set_settings()
- PandasIndexer.xs()
- Pickleable.decode_config()
- Pickleable.decode_config_node()
- Pickleable.dumps()
- Pickleable.encode_config()
- Pickleable.encode_config_node()
- Pickleable.file_exists()
- Pickleable.getsize()
- Pickleable.load()
- Pickleable.loads()
- Pickleable.modify_state()
- Pickleable.resolve_file_path()
- Pickleable.save()
- PlotsBuilderMixin.build_subplots_doc()
- PlotsBuilderMixin.override_subplots_doc()
- PlotsBuilderMixin.plots()
- StatsBuilderMixin.build_metrics_doc()
- StatsBuilderMixin.override_metrics_doc()
- StatsBuilderMixin.stats()
- Wrapping.regroup()
- Wrapping.resample()
- Wrapping.resolve_stack_kwargs()
- Wrapping.select_col()
- Wrapping.select_col_from_obj()
- Wrapping.split()

Subclasses

- ReturnsSRAccessor
- SignalsSRAccessor
- Vbt_SRAccessor

### fit_pattern method

    GenericSRAccessor.fit_pattern(
        pattern,
        interp_mode='mixed',
        rescale_mode='minmax',
        vmin=nan,
        vmax=nan,
        pmin=nan,
        pmax=nan,
        invert=False,
        error_type='absolute',
        max_error=nan,
        max_error_interp_mode=None,
        jitted=None
    )

See fit_pattern_nb().

### to_renko method

    GenericSRAccessor.to_renko(
        brick_size,
        relative=False,
        start_value=None,
        max_out_len=None,
        reset_index=False,
        return_uptrend=False,
        jitted=None,
        wrap_kwargs=None
    )

See to_renko_1d_nb().

### to_renko_ohlc method

    GenericSRAccessor.to_renko_ohlc(
        brick_size,
        relative=False,
        start_value=None,
        max_out_len=None,
        reset_index=False,
        jitted=None,
        wrap_kwargs=None
    )

See to_renko_ohlc_1d_nb().

## TransformerT class

    TransformerT(
        *args,
        **kwargs
    )

Base class for protocol classes.

Protocol classes are defined as::

    class Proto(Protocol):
        def meth(self) -> int:
            ...

Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing), for example::

__ class C__

    def meth(self) -> int:
        return 0

def func(x: Proto) -> int: return x.meth()

func(C()) # Passes static type check

See PEP 544 for details. Protocol classes decorated with @typing.runtime_checkable act as simple-minded runtime protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes can be generic, they are defined as::

    class GenProto(Protocol[T]):
        def meth(self) -> T:
            ...

Superclasses

- `typing.Generic`
- `typing.Protocol`

### fit_transform method

    TransformerT.fit_transform(
        *args,
        **kwargs
    )

### transform method

    TransformerT.transform(
        *args,
        **kwargs
    )

#### Cookie consent

We use cookies to recognize your repeated visits and preferences, as well as to measure the effectiveness of our documentation and whether users find what they're searching for. With your consent, you're helping us to make our documentation better.

- Google Analytics
- GitHub

Manage settings