pandas.Series.resample

pandas 3.1.1 · Series and accessors · method

Create time bins from a datetime-like axis, then reduce, fill or upsample within those bins.

Call syntax

Series.resample(…) Full signature
Series.resample(
    rule,
    closed=None,
    label=None,
    convention='start',
    on=None,
    level=None,
    origin='start_day',
    offset=None,
    group_keys=False,
)

Run the example

Edit the example and select Run Python to see the result.

Parameters

ParameterRequirementAccepted values and behavior
rule Required
Positional or keyword
DateOffset, Timedelta or str

Specify the target frequency or rule used to construct time bins.

closed Optional
Positional or keyword
Default None
{'right', 'left'}

Choose which interval boundaries are included.

label Optional
Positional or keyword
Default None
{'right', 'left'}

Provide the label used to identify an entry or mark a result.

convention Optional
Positional or keyword
Default 'start'
{'start', 'end', 's', 'e'}
on Optional
Positional or keyword
Default None
str

Choose the shared key columns or name the axis column used by the operation.

level Optional
Positional or keyword
Default None
str or int

Choose an index level by name or integer position.

origin Optional
Positional or keyword
Default 'start_day'
Timestamp or str

Choose the reference timestamp or origin from which a numeric time or bin is measured.

offset Optional
Positional or keyword
Default None
Timedelta or str

Shift the origin or boundary used to align time bins or labels.

group_keys Optional
Positional or keyword
Default False
bool

Choose whether the grouping keys become index levels in the result.

Returns

pandas.api.typing.Resampler