MCPcopy Create free account
hub / github.com/dask/dask / Resampler

Class Resampler

dask/dataframe/tseries/resample.py:278–374  ·  view source on GitHub ↗

Aggregate using one or more operations The purpose of this class is to expose an API similar to Pandas' `Resampler` for dask-expr

Source from the content-addressed store, hash-verified

276
277
278class Resampler:
279 """Aggregate using one or more operations
280
281 The purpose of this class is to expose an API similar
282 to Pandas' `Resampler` for dask-expr
283 """
284
285 def __init__(self, obj, rule, **kwargs):
286 if obj.divisions[0] is None:
287 msg = (
288 "Can only resample dataframes with known divisions\n"
289 "See https://docs.dask.org/en/latest/dataframe-design.html#partitions\n"
290 "for more information."
291 )
292 raise ValueError(msg)
293 self.obj = obj
294 self.rule = rule
295 self.kwargs = kwargs
296
297 def _single_agg(self, expr_cls, how_args=(), how_kwargs=None):
298 return new_collection(
299 expr_cls(
300 self.obj,
301 self.rule,
302 self.kwargs,
303 how_args=how_args,
304 how_kwargs=how_kwargs,
305 )
306 )
307
308 @derived_from(pd_Resampler)
309 def count(self):
310 return self._single_agg(ResampleCount)
311
312 @derived_from(pd_Resampler)
313 def sum(self):
314 return self._single_agg(ResampleSum)
315
316 @derived_from(pd_Resampler)
317 def prod(self):
318 return self._single_agg(ResampleProd)
319
320 @derived_from(pd_Resampler)
321 def mean(self):
322 return self._single_agg(ResampleMean)
323
324 @derived_from(pd_Resampler)
325 def min(self):
326 return self._single_agg(ResampleMin)
327
328 @derived_from(pd_Resampler)
329 def max(self):
330 return self._single_agg(ResampleMax)
331
332 @derived_from(pd_Resampler)
333 def first(self):
334 return self._single_agg(ResampleFirst)
335

Callers 1

resampleMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected