re-arrange code segments

This commit is contained in:
Florian Förster 2025-04-11 13:10:39 +02:00
parent da594fb5ba
commit 8501f551b2

View File

@ -254,32 +254,13 @@ def _process_sales(
# Option A: pad data frame with zero values --> could impede forecast algorithm # Option A: pad data frame with zero values --> could impede forecast algorithm
# Option B: calculate next index based on timedelta # Option B: calculate next index based on timedelta
stride = dopt_basics.datetime.timedelta_from_val(365, TimeUnitsTimedelta.DAYS) stride = dopt_basics.datetime.timedelta_from_val(365, TimeUnitsTimedelta.DAYS)
dates = cast(pd.DatetimeIndex, monthly_sum.index) dates = cast(pd.DatetimeIndex, monthly_sum.index)
min_date = dates.min() min_date = dates.min()
stride = dopt_basics.datetime.timedelta_from_val(365, TimeUnitsTimedelta.DAYS)
dates = cast(pd.DatetimeIndex, monthly_sum.index)
min_date = dates.min()
# print("dates: ", dates)
# ?? --- new: use monthly basis for time windows # ?? --- new: use monthly basis for time windows
# baseline: 3 years - 36 months # baseline: 3 years - 36 months
# starting_date = datetime.datetime.now() - relativedelta(months=36) starting_date = datetime.datetime.now() - relativedelta(months=36)
starting_date = dates.max() - relativedelta(months=36)
# start_index = next(
# (i for i, date in enumerate(dates) if date >= starting_date), len(dates) - 1
# )
# print("start idx: ", start_index, "length dates: ", len(dates))
starting_date = datetime.datetime.now() - relativedelta(months=12)
# starting_date = dates.max() - relativedelta(months=36) # starting_date = dates.max() - relativedelta(months=36)
# start_index = next(
# (i for i, date in enumerate(dates) if date >= starting_date), len(dates) - 1
# )
# print("start idx: ", start_index, "length dates: ", len(dates))
def get_index_date( def get_index_date(
dates: pd.DatetimeIndex, dates: pd.DatetimeIndex,