Resample time series in pandas to a weekly interval

2daaa picture 2daaa · Jan 25, 2013 · Viewed 33.9k times · Source

How do I resample a time series in pandas to a weekly frequency where the weeks start on an arbitrary day? I see that there's an optional keyword base but it only works for intervals shorter than a day.

Answer

Andy Hayden picture Andy Hayden · Jan 25, 2013

You can pass anchored offsets to resample, among other options they cover this case.

For example the weekly frequency from Monday:

ts.resample('W-MON')