MCPcopy
hub / github.com/amazon-science/chronos-forecasting / create_df

Function create_df

test/util.py:17–28  ·  view source on GitHub ↗

Helper to create test context DataFrames.

(series_ids=["A", "B"], n_points=[10, 10], target_cols=["target"], covariates=None, freq="h")

Source from the content-addressed store, hash-verified

15
16
17def create_df(series_ids=["A", "B"], n_points=[10, 10], target_cols=["target"], covariates=None, freq="h"):
18 """Helper to create test context DataFrames."""
19 series_dfs = []
20 for series_id, length in zip(series_ids, n_points):
21 series_data = {"item_id": series_id, "timestamp": pd.date_range(end="2001-10-01", periods=length, freq=freq)}
22 for target_col in target_cols:
23 series_data[target_col] = np.random.randn(length)
24 if covariates:
25 for cov in covariates:
26 series_data[cov] = np.random.randn(length)
27 series_dfs.append(pd.DataFrame(series_data))
28 return pd.concat(series_dfs, ignore_index=True)
29
30
31def create_future_df(forecast_start_times: list, series_ids=["A", "B"], n_points=[5, 5], covariates=None, freq="h"):

Calls

no outgoing calls