Ryan Saxe Ryan Saxe - 1 year ago 238
Python Question

pandas resample documentation

So I completely understand how to use resample, but the documentation does not do a good job explaining the options.

So most options in the

function are pretty straight forward except for these two:

  • rule : the offset string or object representing target conversion

  • how : string, method for down- or re-sampling, default to ‘mean’

So from looking at as many examples as I found online I can see for rule you can do
for day,
for minutes,
for milliseconds, but that is all I could find.

for how I have seen the following:
, and
where nx is the first letter of each column index.

So is there somewhere in the documentation that I am missing that displays every option for
's rule and how inputs? If yes, where because I could not find it. If no, what are all the options for them?

Answer Source
B       business day frequency
C       custom business day frequency (experimental)
D       calendar day frequency
W       weekly frequency
M       month end frequency
SM      semi-month end frequency (15th and end of month)
BM      business month end frequency
CBM     custom business month end frequency
MS      month start frequency
SMS     semi-month start frequency (1st and 15th)
BMS     business month start frequency
CBMS    custom business month start frequency
Q       quarter end frequency
BQ      business quarter endfrequency
QS      quarter start frequency
BQS     business quarter start frequency
A       year end frequency
BA      business year end frequency
AS      year start frequency
BAS     business year start frequency
BH      business hour frequency
H       hourly frequency
T       minutely frequency
S       secondly frequency
L       milliseonds
U       microseconds
N       nanoseconds

See the timeseries documentation. It includes a list of offsets (and 'anchored' offsets), and a section about resampling.

Note that there isn't a list of all the different how options, because it can be any NumPy array function and any function that is available via groupby dispatching can be passed to how by name.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download