From 394f3dce4d3a4f5a54c89ea0466fb82a834a83a8 Mon Sep 17 00:00:00 2001 From: Andreas Motl Date: Thu, 18 Apr 2024 22:56:04 +0200 Subject: [PATCH] TSML: Fix CrateDB write sync with `timeseries-anomaly-detection.ipynb` This may mitigate the error `ValueError: Found array with 0 sample(s)`. --- topic/timeseries/timeseries-anomaly-detection.ipynb | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/topic/timeseries/timeseries-anomaly-detection.ipynb b/topic/timeseries/timeseries-anomaly-detection.ipynb index 737a08c0..08d7e4cb 100644 --- a/topic/timeseries/timeseries-anomaly-detection.ipynb +++ b/topic/timeseries/timeseries-anomaly-detection.ipynb @@ -110,11 +110,14 @@ "\n", "engine = sa.create_engine(CONNECTION_STRING, echo=os.environ.get('DEBUG'))\n", "\n", - "query_create_table = 'CREATE TABLE machine_data (\"timestamp\" TIMESTAMP, \"value\" DOUBLE PRECISION)' \n", - "query_copy_from = \"COPY machine_data FROM 'https://github.com/crate/cratedb-datasets/raw/main/timeseries/nab-machine-failure.csv';\"\n", + "sql_ddl = 'CREATE TABLE machine_data (\"timestamp\" TIMESTAMP, \"value\" DOUBLE PRECISION)'\n", + "sql_load = \"COPY machine_data FROM 'https://github.com/crate/cratedb-datasets/raw/main/timeseries/nab-machine-failure.csv';\"\n", + "sql_refresh = \"REFRESH TABLE machine_data;\"\n", + "\n", "with engine.connect() as conn:\n", - " conn.execute(sa.text(query_create_table))\n", - " conn.execute(sa.text(query_copy_from))\n" + " conn.execute(sa.text(sql_ddl))\n", + " conn.execute(sa.text(sql_load))\n", + " conn.execute(sa.text(sql_refresh))" ] }, {