Skip to content

Commit

Permalink
Notebook: Document aggregation_methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Erik Parmann committed Aug 9, 2019
1 parent b8ef3d5 commit 2e84c08
Showing 1 changed file with 248 additions and 3 deletions.
251 changes: 248 additions & 3 deletions examples/Gordo-Workflow-Semi-Low-Level.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,257 @@
"xhat"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Using custom or multiple aggregation methods\n",
"TimeSeriesDataset supports customization of the aggregation method used for the resampled buckets, and it can even use multiple aggregation methods. "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Custom aggregation method"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": []
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>asgb.19ZT3950%2FY%2FPRIM</th>\n",
" <th>asgb.19PST3925%2FDispMeasOut%2FPRIM</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>2016-07-01 07:40:00+00:00</th>\n",
" <td>100.032417</td>\n",
" <td>46.330772</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2016-07-01 07:50:00+00:00</th>\n",
" <td>100.032417</td>\n",
" <td>46.330772</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2016-07-01 08:00:00+00:00</th>\n",
" <td>100.032417</td>\n",
" <td>46.330772</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2016-07-01 08:10:00+00:00</th>\n",
" <td>100.032417</td>\n",
" <td>46.330772</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2016-07-01 08:20:00+00:00</th>\n",
" <td>100.032417</td>\n",
" <td>46.330772</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" asgb.19ZT3950%2FY%2FPRIM \\\n",
"2016-07-01 07:40:00+00:00 100.032417 \n",
"2016-07-01 07:50:00+00:00 100.032417 \n",
"2016-07-01 08:00:00+00:00 100.032417 \n",
"2016-07-01 08:10:00+00:00 100.032417 \n",
"2016-07-01 08:20:00+00:00 100.032417 \n",
"\n",
" asgb.19PST3925%2FDispMeasOut%2FPRIM \n",
"2016-07-01 07:40:00+00:00 46.330772 \n",
"2016-07-01 07:50:00+00:00 46.330772 \n",
"2016-07-01 08:00:00+00:00 46.330772 \n",
"2016-07-01 08:10:00+00:00 46.330772 \n",
"2016-07-01 08:20:00+00:00 46.330772 "
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Remember to load the first cell to have the required imports\n",
"dataset = TimeSeriesDataset(from_ts=dateutil.parser.isoparse('2016-07-01T00:10:00+00:00'),\n",
" to_ts=dateutil.parser.isoparse('2017-01-01T00:00:00+00:00'),\n",
" tag_list=[\n",
" 'asgb.19ZT3950%2FY%2FPRIM',\n",
" 'asgb.19PST3925%2FDispMeasOut%2FPRIM'\n",
" ],\n",
" aggregation_methods=\"max\",\n",
" data_provider=data_provider)\n",
"X, y = dataset.get_data()\n",
"X.head()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Multiple aggregation methods\n",
"When using multiple aggregation methods the returned dataframe will have multi-level columns, with the tag-name as top-level and aggregation method as the second level. "
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead tr th {\n",
" text-align: left;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr>\n",
" <th>tag</th>\n",
" <th colspan=\"3\" halign=\"left\">asgb.19ZT3950%2FY%2FPRIM</th>\n",
" <th colspan=\"3\" halign=\"left\">asgb.19PST3925%2FDispMeasOut%2FPRIM</th>\n",
" </tr>\n",
" <tr>\n",
" <th>aggregation_method</th>\n",
" <th>max</th>\n",
" <th>min</th>\n",
" <th>mean</th>\n",
" <th>max</th>\n",
" <th>min</th>\n",
" <th>mean</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>2016-07-01 07:40:00+00:00</th>\n",
" <td>100.032417</td>\n",
" <td>99.945984</td>\n",
" <td>99.989201</td>\n",
" <td>46.330772</td>\n",
" <td>46.327229</td>\n",
" <td>46.329</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2016-07-01 07:50:00+00:00</th>\n",
" <td>100.032417</td>\n",
" <td>99.945984</td>\n",
" <td>99.989201</td>\n",
" <td>46.330772</td>\n",
" <td>46.327229</td>\n",
" <td>46.329</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2016-07-01 08:00:00+00:00</th>\n",
" <td>100.032417</td>\n",
" <td>99.945984</td>\n",
" <td>99.989201</td>\n",
" <td>46.330772</td>\n",
" <td>46.327229</td>\n",
" <td>46.329</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2016-07-01 08:10:00+00:00</th>\n",
" <td>100.032417</td>\n",
" <td>99.945984</td>\n",
" <td>99.989201</td>\n",
" <td>46.330772</td>\n",
" <td>46.327229</td>\n",
" <td>46.329</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2016-07-01 08:20:00+00:00</th>\n",
" <td>100.032417</td>\n",
" <td>99.945984</td>\n",
" <td>99.989201</td>\n",
" <td>46.330772</td>\n",
" <td>46.327229</td>\n",
" <td>46.329</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
"tag asgb.19ZT3950%2FY%2FPRIM \\\n",
"aggregation_method max min mean \n",
"2016-07-01 07:40:00+00:00 100.032417 99.945984 99.989201 \n",
"2016-07-01 07:50:00+00:00 100.032417 99.945984 99.989201 \n",
"2016-07-01 08:00:00+00:00 100.032417 99.945984 99.989201 \n",
"2016-07-01 08:10:00+00:00 100.032417 99.945984 99.989201 \n",
"2016-07-01 08:20:00+00:00 100.032417 99.945984 99.989201 \n",
"\n",
"tag asgb.19PST3925%2FDispMeasOut%2FPRIM \\\n",
"aggregation_method max min \n",
"2016-07-01 07:40:00+00:00 46.330772 46.327229 \n",
"2016-07-01 07:50:00+00:00 46.330772 46.327229 \n",
"2016-07-01 08:00:00+00:00 46.330772 46.327229 \n",
"2016-07-01 08:10:00+00:00 46.330772 46.327229 \n",
"2016-07-01 08:20:00+00:00 46.330772 46.327229 \n",
"\n",
"tag \n",
"aggregation_method mean \n",
"2016-07-01 07:40:00+00:00 46.329 \n",
"2016-07-01 07:50:00+00:00 46.329 \n",
"2016-07-01 08:00:00+00:00 46.329 \n",
"2016-07-01 08:10:00+00:00 46.329 \n",
"2016-07-01 08:20:00+00:00 46.329 "
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Remember to load the first cell to have the required imports\n",
"dataset = TimeSeriesDataset(from_ts=dateutil.parser.isoparse('2016-07-01T00:10:00+00:00'),\n",
" to_ts=dateutil.parser.isoparse('2017-01-01T00:00:00+00:00'),\n",
" tag_list=[\n",
" 'asgb.19ZT3950%2FY%2FPRIM',\n",
" 'asgb.19PST3925%2FDispMeasOut%2FPRIM'\n",
" ],\n",
" aggregation_methods=[\"max\",\"min\",\"mean\"],\n",
" data_provider=data_provider)\n",
"X, y = dataset.get_data()\n",
"X.head()"
]
}
],
"metadata": {
Expand Down

0 comments on commit 2e84c08

Please sign in to comment.