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

#
base module

Base classes and functions for resampling.

## Resampler class

    Resampler(
        source_index,
        target_index,
        source_freq=None,
        target_freq=None,
        silence_warnings=None
    )

Class that exposes methods to resample index.

Args

`source_index` :`index_like`
  Index being resampled.
`target_index` :`index_like`
  Index resulted from resampling.
`source_freq` :`frequency_like` or `bool`

  Frequency or date offset of the source index.

  Set to False to force-set the frequency to None.

`target_freq` :`frequency_like` or `bool`

  Frequency or date offset of the target index.

  Set to False to force-set the frequency to None.

`silence_warnings` :`bool`
  Whether to silence all warnings.

Superclasses

- Cacheable
- Chainable
- Comparable
- Configured
- HasSettings
- Pickleable
- Prettified

Inherited members

- Cacheable.get_ca_setup()
- Chainable.pipe()
- Configured.config
- Configured.copy()
- Configured.equals()
- Configured.get_writeable_attrs()
- Configured.prettify()
- Configured.rec_state
- 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()
- 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()

### from_date_range class method

    Resampler.from_date_range(
        source_index,
        *args,
        source_freq=None,
        silence_warnings=None,
        **kwargs
    )

Build Resampler from date_range().

### from_pd_resample class method

    Resampler.from_pd_resample(
        source_index,
        *args,
        source_freq=None,
        silence_warnings=True,
        **kwargs
    )

Build Resampler from pandas.DataFrame.resample.

### from_pd_resampler class method

    Resampler.from_pd_resampler(
        pd_resampler,
        source_freq=None,
        silence_warnings=True
    )

Build Resampler from pandas.core.resample.Resampler.

### get_lbound_index class method

    Resampler.get_lbound_index(
        index,
        freq=None
    )

Get the left bound of a datetime index.

If `freq` is None, calculates the leftmost bound.

### get_np_source_freq method

    Resampler.get_np_source_freq(
        silence_warnings=None
    )

Frequency or date offset of the source index in NumPy format.

### get_np_target_freq method

    Resampler.get_np_target_freq(
        silence_warnings=None
    )

Frequency or date offset of the target index in NumPy format.

### get_rbound_index class method

    Resampler.get_rbound_index(
        index,
        freq=None
    )

Get the right bound of a datetime index.

If `freq` is None, calculates the rightmost bound.

### index_difference method

    Resampler.index_difference(
        reverse=False,
        return_index=True,
        jitted=None
    )

See index_difference_nb().

### last_before_target_index method

    Resampler.last_before_target_index(
        incl_source=True,
        jitted=None
    )

See last_before_target_index_nb().

### map_bounds_to_source_ranges class method

    Resampler.map_bounds_to_source_ranges(
        source_index=None,
        target_lbound_index=None,
        target_rbound_index=None,
        closed_lbound=True,
        closed_rbound=False,
        skip_not_found=False,
        jitted=None
    )

See map_bounds_to_source_ranges_nb().

Either `target_lbound_index` or `target_rbound_index` must be set. Set `target_lbound_index` and `target_rbound_index` to 'pandas' to use Resampler.get_lbound_index() and Resampler.get_rbound_index() respectively. Also, both allow providing a single datetime string and will automatically broadcast to the Resampler.target_index.

### map_index_to_source_ranges method

    Resampler.map_index_to_source_ranges(
        before=False,
        jitted=None,
        silence_warnings=None
    )

See map_index_to_source_ranges_nb().

If Resampler.target_freq is a date offset, sets is to None and gives a warning. Raises another warning is `target_freq` is None.

### map_to_target_index method

    Resampler.map_to_target_index(
        before=False,
        raise_missing=True,
        return_index=True,
        jitted=None,
        silence_warnings=None
    )

See map_to_target_index_nb().

### resample_source_mask method

    Resampler.resample_source_mask(
        source_mask,
        jitted=None,
        silence_warnings=None
    )

See resample_source_mask_nb().

### silence_warnings property

Frequency or date offset of the target index.

### source_freq property

Frequency or date offset of the source index.

### source_index property

Index being resampled.

### source_lbound_index property

Get the left bound of the source datetime index.

### source_rbound_index property

Get the right bound of the source datetime index.

### target_freq property

Frequency or date offset of the target index.

### target_index property

Index resulted from resampling.

### target_lbound_index property

Get the left bound of the target datetime index.

### target_rbound_index property

Get the right bound of the target datetime index.

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