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
1246
1246
function on the grouped object. This was not nearly as convenient or performant
1247
1247
as the new pandas timeseries API.
1248
1248
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
+
1249
1272
.. _timeseries.periods :
1250
1273
1251
1274
Time Span Representation
You can’t perform that action at this time.
0 commit comments