Returns a Resample object for performing resampling operations. Handles both downsampling and upsampling. The resampled dimension must be a datetime-like coordinate. If any intervals contain no values from the original object, they will be given the value ``NaN``.
(
self,
indexer: Mapping[Hashable, ResampleCompatible | Resampler] | None = None,
*,
skipna: bool | None = None,
closed: SideOptions | None = None,
label: SideOptions | None = None,
offset: pd.Timedelta | datetime.timedelta | str | None = None,
origin: str | DatetimeLike = "start_day",
restore_coord_dims: bool | None = None,
**indexer_kwargs: ResampleCompatible | Resampler,
)
| 7501 | |
| 7502 | @_deprecate_positional_args("v2024.07.0") |
| 7503 | def resample( |
| 7504 | self, |
| 7505 | indexer: Mapping[Hashable, ResampleCompatible | Resampler] | None = None, |
| 7506 | *, |
| 7507 | skipna: bool | None = None, |
| 7508 | closed: SideOptions | None = None, |
| 7509 | label: SideOptions | None = None, |
| 7510 | offset: pd.Timedelta | datetime.timedelta | str | None = None, |
| 7511 | origin: str | DatetimeLike = "start_day", |
| 7512 | restore_coord_dims: bool | None = None, |
| 7513 | **indexer_kwargs: ResampleCompatible | Resampler, |
| 7514 | ) -> DataArrayResample: |
| 7515 | """Returns a Resample object for performing resampling operations. |
| 7516 | |
| 7517 | Handles both downsampling and upsampling. The resampled |
| 7518 | dimension must be a datetime-like coordinate. If any intervals |
| 7519 | contain no values from the original object, they will be given |
| 7520 | the value ``NaN``. |
| 7521 | |
| 7522 | Parameters |
| 7523 | ---------- |
| 7524 | indexer : Mapping of Hashable to str, datetime.timedelta, pd.Timedelta, pd.DateOffset, or Resampler, optional |
| 7525 | Mapping from the dimension name to resample frequency [1]_. The |
| 7526 | dimension must be datetime-like. |
| 7527 | skipna : bool, optional |
| 7528 | Whether to skip missing values when aggregating in downsampling. |
| 7529 | closed : {"left", "right"}, optional |
| 7530 | Side of each interval to treat as closed. |
| 7531 | label : {"left", "right"}, optional |
| 7532 | Side of each interval to use for labeling. |
| 7533 | origin : {'epoch', 'start', 'start_day', 'end', 'end_day'}, pd.Timestamp, datetime.datetime, np.datetime64, or cftime.datetime, default 'start_day' |
| 7534 | The datetime on which to adjust the grouping. The timezone of origin |
| 7535 | must match the timezone of the index. |
| 7536 | |
| 7537 | If a datetime is not used, these values are also supported: |
| 7538 | - 'epoch': `origin` is 1970-01-01 |
| 7539 | - 'start': `origin` is the first value of the timeseries |
| 7540 | - 'start_day': `origin` is the first day at midnight of the timeseries |
| 7541 | - 'end': `origin` is the last value of the timeseries |
| 7542 | - 'end_day': `origin` is the ceiling midnight of the last day |
| 7543 | offset : pd.Timedelta, datetime.timedelta, or str, default is None |
| 7544 | An offset timedelta added to the origin. |
| 7545 | restore_coord_dims : bool, optional |
| 7546 | If True, also restore the dimension order of multi-dimensional |
| 7547 | coordinates. |
| 7548 | **indexer_kwargs : str, datetime.timedelta, pd.Timedelta, pd.DateOffset, or Resampler |
| 7549 | The keyword arguments form of ``indexer``. |
| 7550 | One of indexer or indexer_kwargs must be provided. |
| 7551 | |
| 7552 | Returns |
| 7553 | ------- |
| 7554 | resampled : core.resample.DataArrayResample |
| 7555 | This object resampled. |
| 7556 | |
| 7557 | Examples |
| 7558 | -------- |
| 7559 | Downsample monthly time-series data to seasonal data: |
| 7560 |