Skip to content

Enhance timeseries documentation #11242

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions doc/source/timeseries.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1050,6 +1050,29 @@ previous versions, resampling had to be done using a combination of
function on the grouped object. This was not nearly convenient or performant as
the new pandas timeseries API.

Sparse timeseries
~~~~~~~~~~~~~~~~~

If your timeseries are sparse, be aware that upsampling will generate a lot of
intermediate points filled with whatever passed as ``fill_method``. What
``resample`` does is basically a group by and then applying an aggregation
method on each of its groups, which can also be achieve with something like the
following.

.. ipython:: python

def round(t, freq):
# round a Timestamp to a specified freq
return Timestamp((t.value // freq.delta.value) * freq.delta.value)

from functools import partial

rng = date_range('1/1/2012', periods=100, freq='S')

ts = Series(randint(0, 500, len(rng)), index=rng)

ts.groupby(partial(round, freq=offsets.Minute(3))).sum()

.. _timeseries.periods:

Time Span Representation
Expand Down