File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -1246,6 +1246,29 @@ previous versions, resampling had to be done using a combination of
12461246function on the grouped object. This was not nearly as convenient or performant
12471247as the new pandas timeseries API.
12481248
1249+ Sparse timeseries
1250+ ~~~~~~~~~~~~~~~~~
1251+
1252+ If your timeseries are sparse, be aware that upsampling will generate a lot of
1253+ intermediate points filled with whatever passed as ``fill_method ``. What
1254+ ``resample `` does is basically a group by and then applying an aggregation
1255+ method on each of its groups, which can also be achieve with something like the
1256+ following.
1257+
1258+ .. ipython :: python
1259+
1260+ def round (t , freq ):
1261+ # round a Timestamp to a specified freq
1262+ return Timestamp((t.value // freq.delta.value) * freq.delta.value)
1263+
1264+ from functools import partial
1265+
1266+ rng = date_range(' 1/1/2012' , periods = 100 , freq = ' S' )
1267+
1268+ ts = Series(randint(0 , 500 , len (rng)), index = rng)
1269+
1270+ ts.groupby(partial(round , freq = offsets.Minute(3 ))).sum()
1271+
12491272 .. _timeseries.periods :
12501273
12511274Time Span Representation
You can’t perform that action at this time.
0 commit comments