{ "cells": [ { "cell_type": "markdown", "id": "41296cc6-9d84-47c5-8a92-2d292f6f3c4a", "metadata": { "papermill": { "duration": 0.011316, "end_time": "2024-01-31T17:50:21.685261", "exception": false, "start_time": "2024-01-31T17:50:21.673945", "status": "completed" }, "tags": [] }, "source": [ "# Processing" ] }, { "cell_type": "code", "execution_count": 1, "id": "9286e0b8-3c78-4b0f-943c-d219e9840dfe", "metadata": { "ExecuteTime": { "end_time": "2023-11-20T17:50:48.022312300Z", "start_time": "2023-11-20T17:50:47.944632100Z" }, "papermill": { "duration": 0.015118, "end_time": "2024-01-31T17:50:21.706301", "exception": false, "start_time": "2024-01-31T17:50:21.691183", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "# Import to be able to import python package from src\n", "import sys\n", "sys.path.insert(0, '../../src')" ] }, { "cell_type": "code", "execution_count": 2, "id": "2028eed7-b1c3-4c9e-b6a0-00433caa7d0f", "metadata": { "ExecuteTime": { "end_time": "2023-11-20T17:50:56.596807200Z", "start_time": "2023-11-20T17:50:47.951738100Z" }, "papermill": { "duration": 2.555444, "end_time": "2024-01-31T17:50:24.265958", "exception": false, "start_time": "2024-01-31T17:50:21.710514", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "import pandas as pd\n", "import numpy as np\n", "import ontime as on\n", "from ontime.core.plotting._marks.area import area" ] }, { "cell_type": "markdown", "id": "e24da8ab-6a83-4c2f-9ff0-c633d4693a91", "metadata": { "papermill": { "duration": 0.00259, "end_time": "2024-01-31T17:50:24.271298", "exception": false, "start_time": "2024-01-31T17:50:24.268708", "status": "completed" }, "tags": [] }, "source": [ "---\n", "## Generation of random time series" ] }, { "cell_type": "code", "execution_count": 3, "id": "0fcb01c4-3990-4c8e-aec4-41bcc7221635", "metadata": { "ExecuteTime": { "end_time": "2023-11-20T17:50:56.618382400Z", "start_time": "2023-11-20T17:50:56.599352900Z" }, "papermill": { "duration": 0.008077, "end_time": "2024-01-31T17:50:24.281886", "exception": false, "start_time": "2024-01-31T17:50:24.273809", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "ts = on.generators.random_walk().generate(start=pd.Timestamp('2022-01-01'), end=pd.Timestamp('2022-12-31'))" ] }, { "cell_type": "markdown", "id": "5af625dd-ba6b-4f3b-9f42-462fe8918c5a", "metadata": { "papermill": { "duration": 0.002987, "end_time": "2024-01-31T17:50:24.287343", "exception": false, "start_time": "2024-01-31T17:50:24.284356", "status": "completed" }, "tags": [] }, "source": [ "---\n", "## Apply function on the whole time series" ] }, { "cell_type": "markdown", "id": "d097ae05-fe76-40b7-bdbe-709150040cbf", "metadata": { "papermill": { "duration": 0.002526, "end_time": "2024-01-31T17:50:24.292325", "exception": false, "start_time": "2024-01-31T17:50:24.289799", "status": "completed" }, "tags": [] }, "source": [ "with Lambda function" ] }, { "cell_type": "code", "execution_count": 4, "id": "186f2463-c1f5-4563-bb70-4f671a3a56d1", "metadata": { "ExecuteTime": { "end_time": "2023-11-20T17:50:56.671509300Z", "start_time": "2023-11-20T17:50:56.617335800Z" }, "papermill": { "duration": 0.014626, "end_time": "2024-01-31T17:50:24.309396", "exception": false, "start_time": "2024-01-31T17:50:24.294770", "status": "completed" }, "tags": [] }, "outputs": [ { "data": { "text/html": [ "
<TimeSeries (DataArray) (time: 5, component: 1, sample: 1)> Size: 40B\n",
"array([[[2.]],\n",
"\n",
" [[2.]],\n",
"\n",
" [[2.]],\n",
"\n",
" [[2.]],\n",
"\n",
" [[2.]]])\n",
"Coordinates:\n",
" * time (time) datetime64[ns] 40B 2022-01-01 2022-01-02 ... 2022-01-05\n",
" * component (component) object 8B 'random_walk'\n",
"Dimensions without coordinates: sample\n",
"Attributes:\n",
" static_covariates: None\n",
" hierarchy: None<TimeSeries (DataArray) (time: 5, component: 1, sample: 1)> Size: 40B\n",
"array([[[2.]],\n",
"\n",
" [[2.]],\n",
"\n",
" [[2.]],\n",
"\n",
" [[2.]],\n",
"\n",
" [[2.]]])\n",
"Coordinates:\n",
" * time (time) datetime64[ns] 40B 2022-01-01 2022-01-02 ... 2022-01-05\n",
" * component (component) object 8B 'random_walk'\n",
"Dimensions without coordinates: sample\n",
"Attributes:\n",
" static_covariates: None\n",
" hierarchy: None<TimeSeries (DataArray) (time: 5, component: 1, sample: 1)> Size: 40B\n",
"array([[[0.10963182]],\n",
"\n",
" [[0.21330887]],\n",
"\n",
" [[1.29061992]],\n",
"\n",
" [[0.42607427]],\n",
"\n",
" [[1.33176918]]])\n",
"Coordinates:\n",
" * time (time) datetime64[ns] 40B 2022-01-01 2022-01-02 ... 2022-01-05\n",
" * component (component) object 8B 'random_walk'\n",
"Dimensions without coordinates: sample\n",
"Attributes:\n",
" static_covariates: None\n",
" hierarchy: None