fix(postprocessing): resample with holes (#27487)

(cherry picked from commit 7f19d296b1)
This commit is contained in:
Ville Brofeldt
2024-03-14 12:02:01 -07:00
committed by Michael S. Molina
parent 017e0fc733
commit 1016fd92f6
2 changed files with 57 additions and 2 deletions

View File

@@ -43,13 +43,16 @@ def resample(
raise InvalidPostProcessingError(_("Resample operation requires DatetimeIndex"))
if method not in RESAMPLE_METHOD:
raise InvalidPostProcessingError(
_("Resample method should in ") + ", ".join(RESAMPLE_METHOD) + "."
_("Resample method should be in ") + ", ".join(RESAMPLE_METHOD) + "."
)
if method == "asfreq" and fill_value is not None:
_df = df.resample(rule).asfreq(fill_value=fill_value)
_df = _df.fillna(fill_value)
elif method == "linear":
_df = df.resample(rule).interpolate()
else:
_df = getattr(df.resample(rule), method)()
if method in ("ffill", "bfill"):
_df = _df.fillna(method=method)
return _df