From 81683f98baf319364164f72df76361f79916411b Mon Sep 17 00:00:00 2001 From: Claire Donnelly Date: Mon, 11 Mar 2024 12:00:09 +0100 Subject: [PATCH] Fix ME to M and doctest --- lilio/resampling.py | 1 - lilio/utils.py | 5 ++--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/lilio/resampling.py b/lilio/resampling.py index 8d4b679..3a0a541 100644 --- a/lilio/resampling.py +++ b/lilio/resampling.py @@ -258,7 +258,6 @@ def resample( ) -> pd.DataFrame: ... -# ruff: noqa: E501 / Ignoring line length issue until pd.Interval fixed to drop time. def resample( calendar: Calendar, input_data: Union[pd.Series, pd.DataFrame, xr.DataArray, xr.Dataset], diff --git a/lilio/utils.py b/lilio/utils.py index 7ecef3f..d0d969f 100644 --- a/lilio/utils.py +++ b/lilio/utils.py @@ -116,12 +116,11 @@ def infer_input_data_freq( if data_freq is None: # Manually infer the frequency data_freq = (data.time.values[1:] - data.time.values[:-1]).min() - if "ME" or "MS" in data_freq: - data_freq = data_freq.replace("ME", "M").replace("MS", "M") - if isinstance(data_freq, str): data_freq.replace("-", "") # Get the absolute frequency + data_freq = data_freq.replace("ME", "M").replace("MS", "M") + if not re.match(r"\d+\D", data_freq): # infer_freq can return "d" for "1d". data_freq = "1" + data_freq