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

#
nb module

Numba-compiled functions for resampling.

## date_range_nb function

    date_range_nb(
        start,
        end,
        freq=numpy.timedelta64(86400000000000,'ns'),
        incl_left=True,
        incl_right=True
    )

Generate a datetime index with nanosecond precision from a date range.

Inspired by pandas.date_range.

## index_difference_nb function

    index_difference_nb(
        source_index,
        target_index
    )

Get the elements in `source_index` not present in `target_index`.

## last_before_target_index_nb function

    last_before_target_index_nb(
        source_index,
        target_index,
        incl_source=True,
        incl_target=False
    )

For each source index, find the position of the last source index between the original source index and the corresponding target index.

## map_bounds_to_source_ranges_nb function

    map_bounds_to_source_ranges_nb(
        source_index,
        target_lbound_index,
        target_rbound_index,
        closed_lbound=True,
        closed_rbound=False,
        skip_not_found=False
    )

Get the source bounds that correspond to the target bounds.

Returns a 2-dim array where the first column is the absolute start index (including) nad the second column is the absolute end index (excluding).

If an element cannot be mapped, the start and end of the range becomes -1.

Note

Both index arrays must be increasing. Repeating values are allowed.

## map_index_to_source_ranges_nb function

    map_index_to_source_ranges_nb(
        source_index,
        target_index,
        target_freq=None,
        before=False
    )

Get the source bounds that correspond to each target index.

If `target_freq` is not None, the right bound is limited by the frequency in `target_freq`. Otherwise, the right bound is the next index in `target_index`.

Returns a 2-dim array where the first column is the absolute start index (including) and the second column is the absolute end index (excluding).

If an element cannot be mapped, the start and end of the range becomes -1.

Note

Both index arrays must be increasing. Repeating values are allowed.

## map_to_target_index_nb function

    map_to_target_index_nb(
        source_index,
        target_index,
        target_freq=None,
        before=False,
        raise_missing=True
    )

Get the index of each from `source_index` in `target_index`.

If `before` is True, applied on elements that come before and including that index. Otherwise, applied on elements that come after and including that index.

If `raise_missing` is True, will throw an error if an index cannot be mapped. Otherwise, the element for that index becomes -1.

## resample_source_mask_nb function

    resample_source_mask_nb(
        source_mask,
        source_index,
        target_index,
        source_freq=None,
        target_freq=None
    )

Resample a source mask to the target index.

Becomes True only if the target bar is fully contained in the source bar. The source bar is represented by a non-interrupting sequence of True values in the source mask.

#### 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