Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"""
Create a swifter resampler object
"""
kwds = {
"rule": rule,
"axis": axis,
"closed": closed,
"label": label,
"convention": convention,
"kind": kind,
"loffset": loffset,
"base": base,
"on": on,
"level": level,
}
return Resampler(
self._obj,
self._npartitions,
self._dask_threshold,
self._scheduler,
self._progress_bar,
self._progress_bar_desc,
**kwds
)
def __init__(
self,
pandas_obj,
npartitions=None,
dask_threshold=1,
scheduler="processes",
progress_bar=True,
progress_bar_desc=None,
allow_dask_on_strings=False,
**kwds
):
super(Resampler, self).__init__(
pandas_obj, npartitions, dask_threshold, scheduler, progress_bar, progress_bar_desc, allow_dask_on_strings
)
self._resampler_kwds = kwds.copy()
self._comparison_pd = self._obj_pd.iloc[: self._npartitions * 2]
self._sample_pd = self._sample_pd.resample(**kwds)
self._obj_pd = self._obj_pd.resample(**kwds)
# Setting dask dataframe `self._obj_dd` to None when there are 0 `self._nrows` because
# swifter will immediately return the pandas form during the apply function if there are 0 `self._nrows`
self._obj_dd = (
self._obj_dd.resample(**{k: v for k, v in kwds.items() if k in ["rule", "closed", "label"]})
if self._nrows
else None
)