@@ -383,7 +383,6 @@ def align_inputs_and_labels(df_y: pd.DataFrame, dfs_x: dict) -> tuple:
383383 index_y_selection = set (df_y .index .values )
384384
385385 for df_x in dfs_x .values ():
386- #print(df_x.head(), len(index_y_selection))
387386 if len (df_x .index .names ) == 1 :
388387 index_y_selection = {
389388 (loc_id , year )
@@ -483,42 +482,42 @@ def interpolate_time_series_data_items(X: list, max_season_window_length: int):
483482 return df_ts
484483
485484
486- def aggregate_time_series_data (df_ts : pd .DataFrame , aggregate_time_series_to : str ):
487- """Aggregate time series data to the specified resolution.
488-
489- Args:
490- df_ts (pd.DataFrame): time series data in daily resolution
491- aggregate_time_series_to (str): resolution of aggregated data
492-
493- Returns:
494- pd.DataFrame with interpolated data
495- """
496- if aggregate_time_series_to not in ["week" , "dekad" ]:
497- raise Exception (
498- f"Unsupported time series aggregation resolution { aggregate_time_series_to } "
499- )
500-
501- if "date" not in df_ts .columns :
502- assert "date" in df_ts .index .names
503- df_ts .reset_index (inplace = True )
504-
505- assert "date" in df_ts .columns
506- if aggregate_time_series_to == "week" :
507- df_ts ["week" ] = df_ts ["date" ].dt .isocalendar ().week
508- else :
509- df_ts ["dekad" ] = df_ts .apply (lambda r : dekad_from_date (r ["date" ]), axis = 1 )
510-
511- ts_aggrs = {k : TIME_SERIES_AGGREGATIONS [k ] for k in TIME_SERIES_PREDICTORS }
512- # Primarily to avoid losing the "date" column.
513- ts_aggrs ["date" ] = "min"
514- df_ts = (
515- df_ts .groupby ([KEY_LOC , KEY_YEAR , aggregate_time_series_to ], observed = True )
516- .agg (ts_aggrs )
517- .reset_index ()
518- )
519- df_ts .drop (columns = [aggregate_time_series_to ], inplace = True )
520-
521- return df_ts
485+ # def aggregate_time_series_data(df_ts: pd.DataFrame, aggregate_time_series_to: str):
486+ # """Aggregate time series data to the specified resolution.
487+ #
488+ # Args:
489+ # df_ts (pd.DataFrame): time series data in daily resolution
490+ # aggregate_time_series_to (str): resolution of aggregated data
491+ #
492+ # Returns:
493+ # pd.DataFrame with interpolated data
494+ # """
495+ # if aggregate_time_series_to not in ["week", "dekad"]:
496+ # raise Exception(
497+ # f"Unsupported time series aggregation resolution {aggregate_time_series_to}"
498+ # )
499+ #
500+ # if "date" not in df_ts.columns:
501+ # assert "date" in df_ts.index.names
502+ # df_ts.reset_index(inplace=True)
503+ #
504+ # assert "date" in df_ts.columns
505+ # if aggregate_time_series_to == "week":
506+ # df_ts["week"] = df_ts["date"].dt.isocalendar().week
507+ # else:
508+ # df_ts["dekad"] = df_ts.apply(lambda r: dekad_from_date(r["date"]), axis=1)
509+ #
510+ # ts_aggrs = {k: TIME_SERIES_AGGREGATIONS[k] for k in TIME_SERIES_PREDICTORS}
511+ # # Primarily to avoid losing the "date" column.
512+ # ts_aggrs["date"] = "min"
513+ # df_ts = (
514+ # df_ts.groupby([KEY_LOC, KEY_YEAR, aggregate_time_series_to], observed=True)
515+ # .agg(ts_aggrs)
516+ # .reset_index()
517+ # )
518+ # df_ts.drop(columns=[aggregate_time_series_to], inplace=True)
519+ #
520+ # return df_ts
522521
523522
524523def make_aligned_tensors (
0 commit comments