Resampler#

Time series resampling operations.

Example#

import pandasCore as pd

# Create time series
dates = pd.date_range('2023-01-01', periods=100, freq='D')
s = pd.Series(range(100), index=dates)

# Downsample to monthly
s.resample('M').mean()

# Upsample to hourly with forward fill
s.resample('H').ffill()

Parameters#

Parameter

Type

Default

Description

rule

str

required

Resampling frequency

axis

int

0

Axis to resample

closed

str

None

Which side of bin is closed

label

str

None

Which bin edge to label with

convention

str

‘start’

For PeriodIndex, ‘start’ or ‘end’

kind

str

None

‘timestamp’ or ‘period’

on

str

None

Column to use for resampling

Frequency Strings#

Alias

Description

S

Second

T, min

Minute

H

Hour

D

Day

W

Week

M

Month end

MS

Month start

Q

Quarter end

QS

Quarter start

A, Y

Year end

AS, YS

Year start

Aggregation Methods#

count(), sum(), mean(), median(), std(), var(), min(), max(), first(), last(), ohlc(), prod(), size(), sem()

Upsampling Methods#

ffill(), bfill(), pad(), backfill(), fillna(method), asfreq(), interpolate()